:root {
  --bg: oklch(0.93 0.025 235);
  --bg-2: oklch(0.97 0.012 245);
  --surface: oklch(0.985 0.01 240 / 0.78);
  --surface-2: oklch(0.94 0.025 240 / 0.64);
  --surface-3: oklch(0.88 0.045 235 / 0.72);
  --ink: oklch(0.22 0.055 258);
  --muted: oklch(0.48 0.05 252);
  --line: oklch(0.78 0.055 238 / 0.72);
  --brand: oklch(0.55 0.18 252);
  --brand-strong: oklch(0.43 0.19 258);
  --aqua: oklch(0.74 0.13 205);
  --gold: oklch(0.78 0.14 82);
  --danger: oklch(0.58 0.19 24);
  --success: oklch(0.64 0.15 165);
  --radius: 18px;
  --radius-sm: 13px;
  --shadow: 0 24px 54px oklch(0.36 0.08 250 / 0.16);
  --soft-shadow: 0 10px 26px oklch(0.38 0.08 245 / 0.12);
  --inner: inset 0 1px 0 oklch(1 0 0 / 0.82), inset 0 -1px 0 oklch(0.65 0.05 235 / 0.15);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, oklch(0.86 0.08 210 / 0.62), transparent 25rem),
    radial-gradient(circle at 82% 18%, oklch(0.78 0.1 260 / 0.42), transparent 28rem),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  color: var(--ink);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked .app-shell {
  filter: blur(10px);
  pointer-events: none;
  user-select: none;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 42% 26%, oklch(0.88 0.08 220 / 0.5), transparent 22rem),
    oklch(0.92 0.025 235 / 0.62);
  backdrop-filter: blur(24px) saturate(1.2);
}

.lock-card {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  border: 1px solid oklch(1 0 0 / 0.78);
  border-radius: 24px;
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow), var(--inner);
  padding: 30px;
}

.lock-mark {
  width: 56px;
  height: 56px;
}

.lock-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.75rem;
}

.lock-card p {
  margin: 0;
  color: var(--muted);
}

.lock-message {
  min-height: 1.2em;
  color: var(--danger) !important;
  font-weight: 800;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 92px;
  padding: 16px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid oklch(0.82 0.04 240 / 0.6);
  background: oklch(0.98 0.008 240 / 0.58);
  backdrop-filter: blur(22px) saturate(1.25);
  color: var(--ink);
  display: grid;
  grid-template-columns: minmax(58px, 1fr) minmax(280px, 560px) minmax(58px, 1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 44px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid oklch(1 0 0 / 0.82);
  border-radius: 16px;
  background:
    linear-gradient(145deg, oklch(0.98 0.02 220 / 0.88), oklch(0.76 0.1 225 / 0.7)),
    var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--soft-shadow), var(--inner);
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.section-label,
.panel-title span,
.metric span,
.selected-project-head span {
  color: var(--muted);
  font-size: 0.88rem;
}

.nav-tabs {
  display: grid;
  grid-column: 2;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 0;
  width: 100%;
  justify-items: center;
}

.nav-tab {
  width: 100%;
  min-height: 58px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  padding: 14px 18px;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 800;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.nav-tab.active,
.nav-tab:hover {
  border-color: oklch(0.75 0.08 235 / 0.7);
  background: oklch(1 0 0 / 0.54);
  color: var(--ink);
  box-shadow: var(--inner);
  transform: translateY(-1px);
}

.main {
  min-width: 0;
  padding: 30px;
}

.record-top-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}

.top-left-tools {
  display: flex;
  justify-content: flex-start;
  margin: 0;
}

.icon-action {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid oklch(1 0 0 / 0.86);
  border-radius: 50%;
  background: linear-gradient(145deg, oklch(1 0 0 / 0.92), oklch(0.82 0.08 230 / 0.62));
  color: var(--brand);
  box-shadow: var(--soft-shadow), var(--inner);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.icon-action:hover,
.icon-action.active {
  background: linear-gradient(145deg, oklch(0.78 0.1 220), var(--brand));
  color: white;
  transform: translateY(-2px) scale(1.03);
}

.today-period-summary {
  position: relative;
  display: block;
  width: 100%;
  min-height: 218px;
  isolation: isolate;
  overflow: hidden;
}

.today-day-section {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: min(86%, 560px);
  gap: 7px;
  border: 1px solid oklch(1 0 0 / 0.62);
  border-radius: 18px;
  background: linear-gradient(160deg, oklch(0.96 0.025 220 / 0.82), oklch(0.82 0.065 225 / 0.58));
  box-shadow: var(--inner), 0 12px 28px oklch(0.34 0.08 245 / 0.12);
  padding: 10px;
  cursor: pointer;
  opacity: 0.76;
  transform: translateX(calc(var(--stack-index) * 34px)) scale(0.96);
  transform-origin: center left;
  transition:
    transform 240ms var(--ease-out-quint),
    opacity 180ms ease,
    filter 180ms ease,
    box-shadow 240ms var(--ease-out-quint);
  z-index: calc(1 + var(--stack-index));
  will-change: transform;
}

.today-day-section:hover,
.today-day-section:focus-visible {
  opacity: 0.94;
  outline: none;
  filter: saturate(1.05);
}

.today-day-section:focus-visible {
  box-shadow:
    0 0 0 3px oklch(0.6 0.16 250 / 0.2),
    var(--inner),
    0 12px 28px oklch(0.34 0.08 245 / 0.12);
}

.today-day-section.is-active {
  opacity: 1;
  transform: translateX(clamp(44px, 10vw, 90px)) scale(1);
  z-index: 5;
  box-shadow: var(--shadow), var(--inner);
}

.today-day-section.is-active .today-period-row {
  animation: summary-row-in 220ms var(--ease-out-quart) both;
}

.today-day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

@keyframes summary-row-in {
  from {
    opacity: 0.62;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.today-day-heading strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.today-period-row {
  display: grid;
  min-height: 42px;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid oklch(1 0 0 / 0.62);
  border-radius: 14px;
  background: linear-gradient(145deg, oklch(1 0 0 / 0.74), oklch(0.84 0.05 230 / 0.46));
  box-shadow: var(--inner), 0 8px 18px oklch(0.38 0.08 245 / 0.08);
  padding: 7px 10px;
  color: var(--ink);
}

.today-period-row.has-record {
  border-color: oklch(0.78 0.09 220 / 0.72);
  background: linear-gradient(145deg, oklch(0.95 0.04 215 / 0.88), oklch(0.8 0.08 225 / 0.58));
}

.today-period-label {
  font-weight: 950;
}

.today-period-projects {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.today-period-projects::-webkit-scrollbar {
  display: none;
}

.today-period-project {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--brand-strong);
  font-weight: 950;
}

.today-period-project strong {
  position: absolute;
  right: -8px;
  bottom: -6px;
  min-width: 24px;
  border: 1px solid oklch(1 0 0 / 0.86);
  border-radius: 999px;
  background: linear-gradient(145deg, oklch(0.96 0.03 220 / 0.96), oklch(0.8 0.09 225 / 0.9));
  box-shadow: 0 4px 9px oklch(0.35 0.08 245 / 0.16);
  color: var(--brand-strong);
  font-size: 0.68rem;
  line-height: 1;
  padding: 3px 5px;
  text-align: center;
  white-space: nowrap;
}

.today-period-empty {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.today-period-dot {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px dashed oklch(0.68 0.05 240 / 0.55);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-header h1 {
  max-width: 760px;
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 2.8rem;
  line-height: 1.05;
  letter-spacing: 0;
  text-wrap: balance;
}

.stats-header {
  justify-content: flex-start;
}

.section-label {
  margin: 0;
  font-weight: 800;
}

.panel {
  border: 1px solid oklch(1 0 0 / 0.72);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow), var(--inner);
  padding: 22px;
  backdrop-filter: blur(18px) saturate(1.18);
  animation: panel-in 320ms var(--ease-out-quart) both;
}

.panel-title,
.panel-subtitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title h2,
.panel-subtitle h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
}

.project-create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  gap: 14px;
}

.entry-detail-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid oklch(0.76 0.055 238 / 0.72);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.56);
  color: var(--ink);
  padding: 12px 13px;
  box-shadow: var(--inner);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid oklch(0.6 0.16 250 / 0.18);
}

input::placeholder,
textarea::placeholder {
  color: oklch(0.48 0.045 252);
}

textarea {
  resize: vertical;
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
}

.primary-action,
.secondary-action,
.small-action,
.quick-dates button {
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 900;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.primary-action:active,
.secondary-action:active,
.small-action:active,
.quick-dates button:active,
.icon-action:active,
.project-bubble:active .round-avatar {
  transform: scale(0.97);
}

.primary-action {
  min-height: 46px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  color: white;
  box-shadow: 0 14px 24px oklch(0.45 0.16 250 / 0.24), inset 0 1px 0 oklch(1 0 0 / 0.34);
  padding: 0 18px;
}

.secondary-action,
.quick-dates button,
.rich-toolbar button,
.image-upload-action {
  border: 1px solid oklch(1 0 0 / 0.78);
  background: linear-gradient(145deg, oklch(1 0 0 / 0.78), oklch(0.82 0.05 230 / 0.5));
  color: var(--ink);
  box-shadow: var(--inner), 0 8px 20px oklch(0.4 0.08 245 / 0.1);
}

.primary-action:hover,
.secondary-action:hover,
.quick-dates button:hover,
.rich-toolbar button:hover,
.image-upload-action:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

.secondary-action {
  padding: 11px 14px;
}

.small-action {
  background: transparent;
  color: var(--danger);
  padding: 8px;
}

.edit-action {
  color: var(--brand);
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.project-create-panel,
.project-panel,
.selected-project-panel,
.timeline-panel {
  margin-top: 16px;
}

.project-orbit {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

.project-bubble {
  display: grid;
  width: 112px;
  gap: 8px;
  justify-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px;
}

.project-bubble .round-avatar {
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    outline-color 180ms ease;
}

.project-bubble:hover .round-avatar,
.project-bubble.active .round-avatar {
  outline-color: oklch(1 0 0 / 0.96);
  box-shadow: 0 0 0 7px oklch(0.68 0.14 230 / 0.18), 0 18px 28px oklch(0.36 0.08 245 / 0.18);
  transform: translateY(-3px) scale(1.04);
}

.project-bubble.active .round-avatar {
  animation: selected-pulse 420ms var(--ease-out-quint);
}

.project-bubble strong {
  width: 100%;
  overflow: hidden;
  color: var(--ink);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-bubble span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.round-avatar {
  position: relative;
  display: grid;
  width: 78px;
  height: 78px;
  overflow: hidden;
  place-items: center;
  border: 2px solid oklch(1 0 0 / 0.75);
  border-radius: 50%;
  outline: 3px solid oklch(0.72 0.08 230 / 0.34);
  background: linear-gradient(145deg, oklch(0.72 0.12 205), var(--brand));
  color: white;
  font-size: 1.4rem;
  font-weight: 950;
  box-shadow: inset 0 2px 0 oklch(1 0 0 / 0.24), var(--soft-shadow);
}

.round-avatar.has-children {
  outline-color: oklch(0.78 0.14 205 / 0.62);
  box-shadow:
    0 0 0 5px oklch(0.82 0.1 210 / 0.28),
    inset 0 2px 0 oklch(1 0 0 / 0.24),
    var(--soft-shadow);
}

.round-avatar.has-children::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  border: 2px solid oklch(1 0 0 / 0.92);
  border-radius: 50%;
  background:
    linear-gradient(90deg, oklch(0.74 0.13 205) 0 45%, transparent 45% 55%, oklch(0.55 0.18 252) 55% 100%),
    oklch(0.96 0.02 230);
  box-shadow: 0 4px 10px oklch(0.32 0.08 245 / 0.22);
}

.round-avatar.large {
  width: 96px;
  height: 96px;
  font-size: 1.75rem;
}

.round-avatar.small {
  width: 44px;
  height: 44px;
  font-size: 1rem;
}

.round-avatar.tiny {
  width: 24px;
  height: 24px;
  border-width: 1px;
  outline-width: 2px;
  font-size: 0.72rem;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.24), 0 5px 10px oklch(0.38 0.08 245 / 0.16);
}

.round-avatar.small.has-children::after,
.round-avatar.tiny.has-children::after,
.round-avatar.mini.has-children::after {
  right: 2px;
  bottom: 2px;
  width: 10px;
  height: 10px;
  border-width: 1px;
}

.round-avatar.mini {
  width: 28px;
  height: 28px;
  border-width: 1px;
  outline-width: 2px;
  font-size: 0.74rem;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.24), 0 6px 12px oklch(0.38 0.08 245 / 0.18);
}

.round-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-project-empty,
.empty-state {
  border: 1px dashed oklch(0.75 0.055 238 / 0.72);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.36);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.selected-project-panel.is-idle {
  display: none;
}

.selected-project-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.selected-project-head h2 {
  margin: 2px 0 4px;
  color: var(--ink);
  font-size: 1.75rem;
}

.subproject-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.subproject-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 62px;
  border: 1px solid oklch(1 0 0 / 0.68);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.4);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
  box-shadow: var(--inner);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.subproject-item:hover {
  border-color: oklch(0.72 0.1 230 / 0.74);
  background: oklch(1 0 0 / 0.62);
  transform: translateY(-1px);
}

.subproject-item span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.subproject-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subproject-item small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.compact-empty {
  padding: 12px;
}

.entries-subtitle {
  margin-top: 4px;
}

.selected-project-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.entry-composer {
  margin-top: 18px;
  border-top: 1px solid oklch(0.78 0.055 238 / 0.62);
  padding-top: 18px;
}

[hidden] {
  display: none !important;
}

.quick-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.quick-dates button {
  padding: 9px 13px;
}

.quick-dates button.active,
.quick-dates button.custom-active {
  border-color: oklch(1 0 0 / 0.9);
  background: linear-gradient(145deg, oklch(0.75 0.12 220), var(--brand));
  color: white;
}

.rich-note-field {
  display: grid;
  gap: 8px;
}

.period-field {
  display: grid;
  gap: 8px;
}

.period-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.period-option {
  position: relative;
  display: inline-flex;
  width: fit-content;
  min-width: 76px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid oklch(1 0 0 / 0.78);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, oklch(1 0 0 / 0.72), oklch(0.82 0.05 230 / 0.46));
  box-shadow: var(--inner), 0 8px 18px oklch(0.4 0.08 245 / 0.1);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.period-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.period-option:has(input:checked) {
  border-color: oklch(1 0 0 / 0.92);
  background: linear-gradient(145deg, oklch(0.75 0.12 220), var(--brand));
  color: white;
}

.field-label {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rich-toolbar button,
.image-upload-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
}

.image-upload-action {
  cursor: pointer;
}

.image-upload-action input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.rich-editor {
  min-height: 160px;
  border: 1px solid oklch(0.76 0.055 238 / 0.72);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.5);
  color: var(--ink);
  padding: 14px;
  line-height: 1.6;
  outline: none;
  box-shadow: var(--inner);
}

.rich-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(0.6 0.16 250 / 0.18);
}

.rich-editor:empty::before {
  color: oklch(0.48 0.045 252);
  content: attr(data-placeholder);
}

.rich-editor img,
.entry-note img {
  display: block;
  max-width: min(100%, 520px);
  max-height: 360px;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.entry-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.entry-note p,
.entry-note div,
.entry-note ul,
.entry-note ol {
  margin: 4px 0;
}

.project-entry-list,
.ranking-list,
.share-list,
.timeline {
  display: grid;
  gap: 10px;
}

.project-entry-item,
.ranking-item,
.timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid oklch(1 0 0 / 0.64);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.42);
  padding: 13px;
  box-shadow: var(--inner);
  animation: list-in 260ms var(--ease-out-quart) both;
}

.entry-highlight {
  animation: record-flash 900ms var(--ease-out-quart) both;
}

.item-main {
  min-width: 0;
}

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

.item-main span {
  color: var(--muted);
  font-size: 0.88rem;
}

.filter-control {
  min-width: 220px;
}

.project-multi-filter {
  display: grid;
  gap: 8px;
  min-width: min(100%, 360px);
}

.project-multi-filter > span {
  color: var(--ink);
  font-weight: 800;
}

.project-filter-options {
  display: flex;
  max-width: 520px;
  max-height: 92px;
  flex-wrap: wrap;
  gap: 8px;
  overflow: auto;
  padding: 2px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: fit-content;
  min-height: 36px;
  border: 1px solid oklch(0.76 0.055 238 / 0.72);
  border-radius: 999px;
  background: oklch(1 0 0 / 0.48);
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 800;
}

.filter-chip:hover,
.filter-chip.active,
.project-filter-chip:has(input:checked) {
  border-color: var(--brand);
  color: var(--ink);
  background: oklch(0.92 0.045 235 / 0.78);
}

.project-filter-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.metric {
  border: 1px solid oklch(1 0 0 / 0.72);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow), var(--inner);
  padding: 18px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 1.75rem;
}

.time-range-panel {
  margin-bottom: 16px;
}

.time-range-panel.is-hidden {
  display: none;
}

.month-range-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
}

.month-range-control label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.inline-month-control {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.time-range-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.compact-metric {
  padding: 14px 16px;
  box-shadow: var(--soft-shadow), var(--inner);
}

.compact-metric strong {
  font-size: 1.25rem;
}

.time-range-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1.1fr);
  gap: 18px;
  align-items: center;
}

.mini-pie-layout {
  grid-template-columns: 140px minmax(0, 1fr);
}

.mini-pie {
  width: 132px;
  height: 132px;
}

.stats-grid,
.stats-visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.stats-visual-grid {
  margin-bottom: 16px;
}

.chart-panel {
  min-height: 280px;
}

.pie-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.pie-chart {
  width: 170px;
  height: 170px;
  border: 5px solid oklch(1 0 0 / 0.7);
  border-radius: 50%;
  background: var(--surface-3);
  box-shadow:
    inset 0 0 0 18px oklch(0.96 0.02 238 / 0.72),
    var(--soft-shadow);
}

.chart-legend,
.bar-chart {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.avatar-legend-row {
  gap: 10px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 86px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row strong {
  text-align: right;
}

.line-chart {
  width: 100%;
  min-height: 220px;
}

.chart-axis {
  stroke: oklch(0.74 0.055 238 / 0.62);
  stroke-width: 2;
}

.chart-grid-line {
  stroke: oklch(0.74 0.055 238 / 0.28);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
  stroke-dasharray: 720;
  stroke-dashoffset: 720;
  animation: draw-line 680ms var(--ease-out-quint) forwards;
}

.project-trend-panel {
  grid-column: 1 / -1;
}

.month-line-chart {
  min-height: 260px;
}

.project-trend-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-label,
.chart-empty-text {
  fill: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.chart-y-label {
  fill: var(--ink);
  font-size: 0.72rem;
}

.compact-legend {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 8px;
}

.chart-point {
  fill: white;
  stroke: var(--brand);
  stroke-width: 3;
}

.chart-avatar-point {
  filter: drop-shadow(0 5px 8px oklch(0.36 0.08 245 / 0.22));
}

.chart-avatar-ring {
  fill: white;
  stroke-width: 3;
}

.chart-avatar-fallback {
  stroke: white;
  stroke-width: 3;
}

.chart-avatar-label {
  fill: white;
  font-size: 0.55rem;
  font-weight: 900;
  pointer-events: none;
}

.month-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 190px;
}

.month-column {
  display: grid;
  align-items: end;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.month-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--aqua), var(--brand));
  box-shadow: 0 10px 18px oklch(0.48 0.12 230 / 0.2);
  transform-origin: bottom;
  animation: grow-bar 380ms var(--ease-out-quart) both;
}

.bar-fill {
  animation: fill-bar 420ms var(--ease-out-quart) both;
  transform-origin: left;
}

.month-column strong {
  color: var(--ink);
  font-size: 0.78rem;
  text-align: center;
}

.bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: oklch(0.78 0.035 238 / 0.5);
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
}

.share-item {
  display: grid;
  gap: 8px;
}

.share-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

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

@keyframes selected-pulse {
  0% {
    transform: translateY(-3px) scale(1.02);
  }
  55% {
    transform: translateY(-4px) scale(1.08);
  }
  100% {
    transform: translateY(-3px) scale(1.04);
  }
}

@keyframes record-flash {
  0% {
    box-shadow: 0 0 0 0 oklch(0.68 0.14 230 / 0.34), var(--inner);
    transform: scale(0.992);
  }
  35% {
    box-shadow: 0 0 0 7px oklch(0.68 0.14 230 / 0.18), var(--inner);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 oklch(0.68 0.14 230 / 0), var(--inner);
    transform: scale(1);
  }
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes grow-bar {
  from {
    transform: scaleY(0.08);
    opacity: 0.5;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes fill-bar {
  from {
    transform: scaleX(0.08);
  }
  to {
    transform: scaleX(1);
  }
}

@media (max-width: 980px) {
  .project-create-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: grid;
    padding-bottom: 0;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
    padding: 12px 14px;
    border-top: 0;
    border-bottom: 1px solid oklch(0.82 0.04 240 / 0.6);
    border-right: 0;
  }

  .brand {
    display: none;
  }

  .nav-tabs {
    grid-column: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .nav-tab {
    min-height: 52px;
    text-align: center;
  }

  .main {
    padding: 20px;
  }

  .page-header,
  .stats-header {
    display: grid;
    align-items: start;
  }

  .time-range-summary,
  .time-range-layout,
  .stats-visual-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 14px;
  }

  .sidebar {
    padding-right: 78px;
  }

  .nav-tabs {
    width: 100%;
  }

  .record-top-tools {
    display: block;
    margin: 4px 0 14px;
  }

  .top-left-tools {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: 20;
    margin: 0;
  }

  .icon-action {
    width: 54px;
    height: 54px;
    font-size: 1.85rem;
  }

  .today-period-summary {
    max-width: none;
    gap: 6px;
  }

  .today-period-row {
    min-height: 50px;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    border-radius: 12px;
    padding: 7px 10px;
  }

  .today-period-label {
    font-size: 0.82rem;
  }

  .today-period-projects {
    min-height: 32px;
    gap: 14px;
  }

  .today-period-project strong {
    right: -9px;
    bottom: -7px;
    min-width: 22px;
    font-size: 0.64rem;
    padding: 3px 4px;
  }

  .page-header h1 {
    font-size: 2rem;
  }

  .project-create-form,
  .split-fields,
  .month-range-control,
  .pie-layout,
  .selected-project-head,
  .selected-project-actions,
  .project-entry-item,
  .ranking-item,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .project-orbit {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 8px;
    row-gap: 28px;
  }

  .project-bubble {
    width: 100%;
    min-width: 0;
    padding: 6px 2px;
  }

  .round-avatar {
    width: 64px;
    height: 64px;
  }

  .today-period-projects .round-avatar.mini {
    width: 30px;
    height: 30px;
    font-size: 0.68rem;
  }

  .today-period-dot {
    width: 24px;
    height: 24px;
  }
}

/* v40 final mobile override: today period rows are today's records, avatar + time badge only. */
@media (max-width: 560px) {
  .sidebar {
    padding-right: 78px !important;
  }

  .top-left-tools {
    position: fixed !important;
    top: 18px !important;
    right: 20px !important;
    z-index: 30 !important;
    margin: 0 !important;
  }

  .icon-action {
    width: 54px !important;
    height: 54px !important;
    font-size: 1.85rem !important;
  }

  .record-top-tools {
    display: block !important;
    margin: 4px 0 14px !important;
  }

  .today-period-row {
    min-height: 50px !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 7px 10px !important;
  }

  .today-period-projects {
    display: flex !important;
    min-height: 32px !important;
    align-items: center !important;
    gap: 14px !important;
    overflow-x: auto !important;
  }

  .today-period-project {
    position: relative !important;
    display: inline-flex !important;
    flex: 0 0 auto !important;
  }

  .today-period-projects .round-avatar.mini {
    width: 30px !important;
    height: 30px !important;
  }

  .today-period-project strong {
    position: absolute !important;
    right: -9px !important;
    bottom: -7px !important;
    min-width: 22px !important;
    border-radius: 999px !important;
    font-size: 0.64rem !important;
    line-height: 1 !important;
    padding: 3px 4px !important;
    white-space: nowrap !important;
  }

  .today-period-empty {
    display: none !important;
  }
}

/* v42: plus button lives in the top nav, and today's period rows use avatar badges. */
.sidebar > .top-left-tools {
  grid-column: 3;
  justify-content: flex-end;
  justify-self: end;
  margin: 0;
}

.record-top-tools {
  display: block;
}

@media (max-width: 560px) {
  .sidebar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 48px !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 22px !important;
  }

  .nav-tabs {
    grid-column: 1 !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
  }

  .sidebar > .top-left-tools {
    position: static !important;
    grid-column: 2 !important;
    display: flex !important;
    justify-content: flex-end !important;
    justify-self: stretch !important;
    margin: 0 !important;
  }

  .icon-action {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    font-size: 1.48rem !important;
    line-height: 1 !important;
  }

  .record-top-tools {
    display: block !important;
    margin: 8px 0 14px !important;
  }

  .today-period-row {
    position: relative !important;
    min-height: 50px !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 7px 12px !important;
  }

  .today-period-projects {
    display: flex !important;
    min-height: 36px !important;
    align-items: center !important;
    gap: 22px !important;
    overflow-x: auto !important;
  }

  .today-period-project {
    position: relative !important;
    display: inline-grid !important;
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
    place-items: center !important;
  }

  .today-period-projects .round-avatar.mini {
    width: 32px !important;
    height: 32px !important;
  }

  .today-period-project strong {
    position: absolute !important;
    right: -14px !important;
    bottom: -8px !important;
    display: inline-grid !important;
    min-width: 24px !important;
    place-items: center !important;
    border: 1px solid oklch(1 0 0 / 0.92) !important;
    border-radius: 999px !important;
    background: linear-gradient(145deg, oklch(0.97 0.03 220 / 0.98), oklch(0.78 0.1 225 / 0.96)) !important;
    color: var(--brand-strong) !important;
    font-size: 0.66rem !important;
    font-weight: 950 !important;
    line-height: 1 !important;
    padding: 3px 5px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  .today-period-time,
  .today-period-empty,
  .today-period-dot {
    display: none !important;
  }
}

/* v43: uppercase period labels and visible hour badges. */
@media (max-width: 560px) {
  .today-period-row {
    overflow: visible !important;
  }

  .today-period-label {
    align-self: center !important;
    color: var(--ink) !important;
    font-size: 1.02rem !important;
    font-weight: 950 !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
  }

  .today-period-projects {
    overflow: visible !important;
    padding: 2px 0 8px !important;
  }

  .today-period-project {
    overflow: visible !important;
  }

  .today-period-project strong {
    display: inline-grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 4 !important;
    right: -15px !important;
    bottom: -9px !important;
    min-width: 26px !important;
    border: 1px solid oklch(1 0 0 / 0.95) !important;
    border-radius: 999px !important;
    background: linear-gradient(145deg, oklch(0.98 0.025 220 / 0.98), oklch(0.78 0.11 225 / 0.96)) !important;
    box-shadow: 0 4px 10px oklch(0.34 0.08 245 / 0.18) !important;
    color: var(--brand-strong) !important;
    font-size: 0.68rem !important;
    font-weight: 950 !important;
    line-height: 1 !important;
    padding: 3px 5px !important;
    place-items: center !important;
    text-align: center !important;
    white-space: nowrap !important;
  }
}

/* v41: compact top button and avatar-corner time badges. */
@media (max-width: 560px) {
  .today-period-summary {
    min-height: 236px !important;
  }

  .today-day-section {
    width: 92% !important;
    padding: 9px !important;
    transform: translateX(calc(var(--stack-index) * 18px)) scale(0.96) !important;
  }

  .today-day-section.is-active {
    transform: translateX(28px) scale(1) !important;
  }

  .today-day-heading {
    padding: 0 2px 2px !important;
  }

  .today-day-heading strong {
    font-size: 1rem !important;
  }

  .sidebar {
    padding-right: 66px !important;
  }

  .top-left-tools {
    top: 22px !important;
    right: 22px !important;
  }

  .icon-action {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.48rem !important;
    line-height: 1 !important;
  }

  .record-top-tools {
    margin-top: 8px !important;
  }

  .today-period-row {
    min-height: 50px !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    padding: 7px 12px !important;
  }

  .today-period-label {
    align-self: start !important;
    padding-top: 2px !important;
  }

  .today-period-projects {
    min-height: 34px !important;
    align-items: center !important;
    gap: 18px !important;
  }

  .today-period-project {
    position: relative !important;
    display: inline-grid !important;
    place-items: center !important;
    width: 34px !important;
    height: 34px !important;
  }

  .today-period-projects .round-avatar.mini {
    width: 32px !important;
    height: 32px !important;
  }

  .today-period-project strong {
    position: absolute !important;
    right: -11px !important;
    bottom: -8px !important;
    min-width: 24px !important;
    border: 1px solid oklch(1 0 0 / 0.92) !important;
    border-radius: 999px !important;
    background: linear-gradient(145deg, oklch(0.97 0.03 220 / 0.98), oklch(0.78 0.1 225 / 0.96)) !important;
    color: var(--brand-strong) !important;
    font-size: 0.66rem !important;
    font-weight: 950 !important;
    line-height: 1 !important;
    padding: 3px 5px !important;
    text-align: center !important;
  }

  .today-period-time,
  .today-period-empty {
    display: none !important;
  }
}
