:root {
  --ink: #101414;
  --muted: #5f6966;
  --line: #dce5df;
  --surface: #fbfcf9;
  --surface-strong: #ffffff;
  --wash: #eef5f1;
  --accent: #007a5a;
  --accent-dark: #005c45;
  --coral: #c9354a;
  --gold: #d4a400;
  --aqua: #107f88;
  --shadow: 0 18px 45px rgba(16, 20, 20, 0.08);
}

body.theme-dark {
  --ink: #edf7f1;
  --muted: #a8b8b0;
  --line: #31443c;
  --surface: #0f1513;
  --surface-strong: #18231f;
  --wash: #0b100f;
  --accent: #72d8b3;
  --accent-dark: #34a47f;
  --coral: #ff6b7a;
  --gold: #f0c74d;
  --aqua: #65cbd0;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--wash);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 122, 90, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #f7faf7 0%, #eef5f1 48%, #f5f7fb 100%);
  background-size: 52px 52px, auto;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body.theme-dark {
  background:
    linear-gradient(90deg, rgba(114, 216, 179, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #0b100f 0%, #111916 56%, #18110f 100%);
  background-size: 52px 52px, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.auth-screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 420px);
  gap: 36px;
  align-items: center;
  min-height: 100vh;
  padding: 48px;
}

.auth-copy {
  max-width: 620px;
}

.auth-copy h1 {
  max-width: 10ch;
  margin: 12px 0 18px;
  font-size: clamp(3rem, 8vw, 6.6rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.auth-copy p:last-child {
  max-width: 48ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.auth-panel {
  display: grid;
  gap: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

body.theme-dark .auth-panel {
  background: rgba(24, 35, 31, 0.92);
}

.auth-panel[data-mode="signin"] .signup-only {
  display: none;
}

.verification-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(0, 122, 90, 0.07);
}

body.theme-dark .verification-box {
  background: rgba(114, 216, 179, 0.08);
}

.verification-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tab,
.rail-button,
.theme-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
}

.theme-button {
  position: static;
}

.auth-theme-button {
  position: absolute;
  top: 24px;
  right: 24px;
}

.auth-tab.is-active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

body.theme-dark .auth-tab.is-active,
body.theme-dark .primary-button {
  color: #07110d;
}

.auth-tab:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 34px 26px;
  color: #f8fffb;
  background: #12352c;
  overflow-y: auto;
  animation: rail-in 520ms ease both;
}

body.theme-dark .rail {
  background: #080d0b;
}

.rail h1 {
  max-width: 10ch;
  margin: 10px 0 0;
  font-size: 2.35rem;
  line-height: 0.98;
  letter-spacing: 0;
}

.rail-copy {
  margin: 16px 0 0;
  color: rgba(248, 255, 251, 0.75);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail .eyebrow,
.rail .small-label {
  color: #8be0c3;
}

.date-block,
.account-block,
.progress-wrap,
.stat-stack,
.filter-list {
  border-top: 1px solid rgba(248, 255, 251, 0.14);
  padding-top: 20px;
}

.date-block span,
.account-block span,
.small-label,
.hint,
.task-meta,
.select-task span,
label span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.date-block span {
  display: block;
  color: rgba(248, 255, 251, 0.68);
}

.date-block strong,
.account-block strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.account-block span {
  display: block;
  color: rgba(248, 255, 251, 0.68);
}

.account-block strong {
  overflow-wrap: anywhere;
}

.rail-button {
  width: 100%;
  margin-top: 14px;
  color: #f8fffb;
  background: rgba(248, 255, 251, 0.1);
  border-color: rgba(248, 255, 251, 0.18);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-wrap strong {
  display: block;
  margin-top: 3px;
}

.progress-ring {
  --progress: 0deg;
  position: relative;
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(#8be0c3 var(--progress), rgba(248, 255, 251, 0.16) 0deg);
  transition: background 280ms ease;
}

.progress-ring::before {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #12352c;
}

.progress-ring span {
  position: relative;
  font-weight: 800;
}

.stat-stack {
  display: grid;
  gap: 12px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stat-row span {
  color: rgba(248, 255, 251, 0.68);
}

.filter-list {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.filter-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: rgba(248, 255, 251, 0.72);
  background: transparent;
  text-align: left;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.filter-button:hover,
.filter-button:focus-visible,
.filter-button.is-active {
  color: #f8fffb;
  background: rgba(248, 255, 251, 0.12);
  transform: translateX(3px);
}

.main-area {
  min-width: 0;
  padding: 32px;
  animation: content-in 620ms ease both;
}

.topbar,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  align-items: center;
  margin-bottom: 24px;
}

.topbar h2,
.panel-heading h3,
.timer-panel h3,
.motivation-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 2.25rem;
}

.topbar-actions,
.timer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 800;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 122, 90, 0.22);
}

.ghost-button {
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line);
}

.danger-button {
  color: #ffffff;
  background: var(--coral);
}

body.theme-dark .danger-button {
  color: #1b080b;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.danger-button:focus-visible,
.icon-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(16, 20, 20, 0.12);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(270px, 0.85fr) minmax(360px, 1.15fr) minmax(260px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.planner-panel,
.task-panel,
.momentum-panel,
.week-panel,
.subject-panel,
.timer-panel,
.motivation-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

body.theme-dark .planner-panel,
body.theme-dark .task-panel,
body.theme-dark .week-panel,
body.theme-dark .subject-panel,
body.theme-dark .timer-panel,
body.theme-dark .motivation-panel,
body.theme-dark .task-item,
body.theme-dark .day-column,
body.theme-dark .subject-item {
  background: rgba(24, 35, 31, 0.88);
}

.planner-panel,
.task-panel,
.week-panel,
.subject-panel {
  padding: 20px;
}

.momentum-panel {
  display: grid;
  gap: 14px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.panel-heading.compact {
  align-items: center;
}

.study-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-panel label,
.study-form label,
.select-task {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  color-scheme: dark;
}

textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 90, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  min-height: 290px;
}

.task-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 92px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.task-item:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 122, 90, 0.35);
  box-shadow: 0 13px 28px rgba(16, 20, 20, 0.1);
}

.task-item.is-done {
  opacity: 0.64;
  border-left-color: var(--muted);
}

.task-check {
  width: 22px;
  height: 22px;
  margin-top: 4px;
  accent-color: var(--accent);
}

.task-body {
  min-width: 0;
}

.task-body strong,
.task-body span {
  display: block;
}

.task-body strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.task-body span {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 3px 8px;
  color: var(--ink);
  background: #edf5f1;
}

body.theme-dark .pill,
body.theme-dark .day-task {
  background: #22342e;
}

.pill.method {
  background: #f1f0ff;
}

.pill.label {
  background: #f1f0ff;
}

body.theme-dark .pill.method,
body.theme-dark .pill.label {
  background: #34304a;
}

.task-notes {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.pill.energy-deep {
  color: #ffffff;
  background: var(--accent-dark);
}

.pill.energy-light {
  background: #fff2b8;
}

body.theme-dark .pill.energy-light {
  color: #15110a;
  background: var(--gold);
}

.pill.energy-steady {
  color: #ffffff;
  background: var(--aqua);
}

.empty-state {
  display: grid;
  min-height: 250px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

body.theme-dark .empty-state {
  background: rgba(24, 35, 31, 0.35);
}

.subject-list .empty-state {
  grid-column: 1 / -1;
}

.timer-panel,
.motivation-panel {
  padding: 18px;
}

.timer-panel {
  display: grid;
  gap: 16px;
}

.timer-panel h3 {
  font-size: 2rem;
}

.timer-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--line);
}

.timer-dot.is-running {
  background: var(--coral);
  animation: pulse 1100ms ease-in-out infinite;
}

.motivation-panel p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.week-panel,
.subject-panel {
  margin-top: 18px;
}

.week-panel {
  max-width: 1160px;
  margin: 0 auto 20px;
  padding: 24px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.day-column {
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.day-column.is-today {
  border-color: rgba(0, 122, 90, 0.46);
  box-shadow: inset 0 0 0 2px rgba(0, 122, 90, 0.08);
}

.day-column strong {
  display: block;
}

.day-column span {
  color: var(--muted);
  font-size: 0.8rem;
}

.day-task {
  display: block;
  margin-top: 8px;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--ink);
  background: #edf5f1;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.subject-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.subject-item {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #ffffff;
}

.subject-item strong,
.subject-item span {
  display: block;
}

.subject-item strong {
  overflow-wrap: anywhere;
}

.subject-item span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.subject-bar {
  height: 7px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: #edf2ef;
}

.subject-bar i {
  display: block;
  width: var(--width);
  height: 100%;
  border-radius: 8px;
  background: var(--accent);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 5;
  max-width: 310px;
  border-radius: 8px;
  padding: 14px 16px;
  color: #ffffff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rail-in {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes content-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(201, 53, 74, 0.34);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(201, 53, 74, 0);
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .workspace-grid {
    grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.1fr);
  }

  .momentum-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .subject-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .auth-screen {
    grid-template-columns: 1fr;
    gap: 26px;
    padding: 34px 18px;
  }

  .auth-copy h1 {
    max-width: 12ch;
  }

  .app-shell {
    display: block;
  }

  .rail {
    position: static;
    height: auto;
    min-height: 0;
  }

  .rail h1 {
    max-width: 14ch;
  }

  .filter-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filter-button {
    text-align: center;
  }

  .filter-button:hover,
  .filter-button:focus-visible,
  .filter-button.is-active {
    transform: translateY(-1px);
  }

  .main-area {
    padding: 24px 18px;
  }

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

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

  .topbar-actions button {
    flex: 1;
  }

  .workspace-grid,
  .momentum-panel {
    grid-template-columns: 1fr;
  }

  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .rail {
    padding: 28px 18px;
  }

  .rail h1 {
    font-size: 2rem;
  }

  .filter-list,
  .form-row,
  .subject-list {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 1.8rem;
  }

  .topbar-actions,
  .timer-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .task-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .task-item .icon-button {
    grid-column: 2;
    justify-self: start;
  }

  .week-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
