:root {
  --bg: #070707;
  --panel: #111111;
  --text: #f2f2f2;
  --muted: #a0a0a0;
  --green: #4caf50;
  --green-soft: #1f4122;
  --cta: #d61d1d;
  --cta-hover: #f03030;
  --line: #2c2c2c;
  --shadow: 0 18px 35px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #163318 0%, var(--bg) 36%),
    linear-gradient(155deg, #0f0f0f, #060606);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  position: relative;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
}

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 1rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.routine-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.routine-nav .btn.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(76, 175, 80, 0.12);
}

.welcome-panel {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
  background: rgba(255, 255, 255, 0.03);
}

.welcome-name {
  margin: 0;
  font: 700 1rem "Rajdhani", sans-serif;
  letter-spacing: 0.02em;
}

.welcome-message {
  margin: 0;
  color: #d6ead8;
  font-size: 0.85rem;
}

.top-message {
  margin: 0;
  max-width: 420px;
  color: #d3f0d6;
  font-size: 0.85rem;
}

.top-message.error {
  color: #ff7c7c;
}

.brand-tag {
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--green);
}

h1,
h2 {
  font-family: "Rajdhani", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 3vw, 2.8rem);
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.panel {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.1rem;
  backdrop-filter: blur(4px);
}

.auth-panel {
  grid-column: span 12;
}

.profile-panel {
  grid-column: span 4;
}

.plan-panel {
  grid-column: span 8;
}

.saved-panel {
  grid-column: span 12;
}

.auth-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.auth-status {
  margin: 0;
  color: #d6ead8;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.auth-grid .cta-row {
  grid-column: 1 / -1;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.app-message {
  margin: 0.85rem 0 0;
  color: #d3f0d6;
  min-height: 1.2rem;
  font-size: 0.9rem;
}

.app-message.error {
  color: #ff7c7c;
}

.panel-subsection {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.012);
}

.generated-subsection {
  border-left: 4px solid #4caf50;
}

.custom-subsection {
  border-left: 4px solid #d61d1d;
}

.plan-mode-note {
  margin: 0;
  color: #d6ead8;
  font-size: 0.9rem;
}

.panel-subsection h3 {
  margin: 0 0 0.7rem;
  font: 600 1.05rem "Rajdhani", sans-serif;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: #dddddd;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0b0b;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.22);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font: 600 0.9rem "Space Grotesk", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--cta);
  color: #fff;
}

.btn-primary:hover {
  background: var(--cta-hover);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border-color: var(--line);
}

.btn-outline:hover {
  border-color: var(--green);
  color: var(--green);
}

.btn-danger {
  background: transparent;
  color: #ff5b5b;
  border-color: #6f2b2b;
}

.btn-danger:hover {
  border-color: #b33939;
}

.cta-row,
.routine-header,
.saved-item,
.saved-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
}

.save-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#saveRoutineNameInput {
  min-width: 220px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 1.2rem;
  color: var(--muted);
}

.hidden {
  display: none;
}

.routine-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.routine-title {
  margin: 0;
  font-size: 1.05rem;
  color: #ffffff;
}

.routine-meta,
.saved-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.routine-weeks {
  display: grid;
  gap: 0.9rem;
}

.week-block {
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.015);
  padding: 0.85rem;
}

.week-block h3 {
  margin: 0;
  font-size: 1rem;
  color: #dff3e1;
}

.week-block ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.week-block li {
  margin-bottom: 0.45rem;
  color: #ececec;
}

.saved-list {
  display: grid;
  gap: 0.7rem;
}

.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.usage-text {
  margin: 0;
  color: #d6ead8;
  font-size: 0.9rem;
}

.saved-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.015);
}

.saved-title {
  margin: 0;
  font-weight: 600;
}

@media (max-width: 950px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .profile-panel,
  .plan-panel,
  .saved-panel {
    grid-column: span 12;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .welcome-panel {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 600px) {
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .auth-head,
  .usage-row,
  .cta-row,
  .routine-header,
  .saved-item {
    flex-direction: column;
    align-items: stretch;
  }

  .saved-actions {
    width: 100%;
    justify-content: stretch;
  }

  .saved-actions .btn {
    flex: 1;
  }
}
