@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #0a0f14;
  --panel: #121923;
  --panel-alt: #0f151e;
  --panel-soft: #0f1620;
  --panel-strong: #1a2431;
  --text: #e8eef6;
  --muted: #97a6b5;
  --accent: #53b7ff;
  --accent-soft: #32d6b0;
  --danger: #ff8d8d;
  --shadow: 0 30px 80px rgba(2, 6, 12, 0.65);
  --ring-track: url(#trackGradient);
  --ring-width: 18;
  --border: rgba(148, 168, 186, 0.2);
  --border-strong: rgba(148, 168, 186, 0.35);
  --panel-glow: rgba(83, 183, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, #15202b 0%, #0b1118 45%, #070b10 100%);
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
}

html.needs-login .app {
  display: none;
}

html.needs-login .login-screen {
  display: grid;
}

html.has-session .login-screen {
  display: none;
}

html.has-session .app {
  display: grid;
}

.login-screen {
  width: min(520px, 92vw);
  display: none;
  place-items: center;
}

.login-card {
  width: 100%;
  background: linear-gradient(150deg, #101826 0%, #0b121a 100%);
  border-radius: 26px;
  padding: 36px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  border: 1px solid rgba(83, 183, 255, 0.08);
}

.login-eyebrow {
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-title {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0.02em;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.login-google-btn {
  width: 100%;
  border: 1px solid rgba(149, 169, 189, 0.45);
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(140deg, #f3f7ff 0%, #e6eefb 100%);
  color: #1a2431;
  box-shadow: 0 10px 22px rgba(5, 12, 20, 0.35);
}

.login-google-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(5, 12, 20, 0.4);
}

.google-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #2c63ff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(36, 52, 74, 0.1);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(148, 168, 186, 0.25);
}

.login-import {
  display: grid;
  gap: 10px;
}

.login-textarea {
  min-height: 110px;
}

.login-input {
  font-size: 15px;
}

.login-btn {
  width: 100%;
  padding: 12px 18px;
}

.login-import-btn {
  width: 100%;
}

.login-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.login-status.success {
  color: var(--accent-soft);
}

.login-status.error {
  color: var(--danger);
}

.login-meta {
  font-size: 12px;
  color: var(--muted);
}

.app {
  width: min(1180px, 94vw);
  min-height: 700px;
  background: linear-gradient(145deg, #141c26 0%, #0e141c 100%);
  border-radius: 26px;
  padding: 32px 36px 36px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: inset 0 0 0 1px var(--border);
}

.icon-btn {
  border: none;
  background: var(--panel-strong);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.icon-btn.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(5, 12, 20, 0.5);
}

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

.date-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.date-main {
  font-size: 20px;
  font-weight: 600;
}

.date-sub {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.date-picker {
  border: none;
  background: #141d29;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
}

.tabs {
  display: flex;
  gap: 8px;
  background: var(--panel);
  padding: 8px;
  border-radius: 14px;
}

.tab {
  border: none;
  background: transparent;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab.active {
  background: #1b2635;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(8, 14, 24, 0.55);
}

.menu-wrap {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 190px;
  padding: 8px;
  border-radius: 14px;
  background: #101926;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(5, 12, 20, 0.6);
  display: grid;
  gap: 4px;
  z-index: 12;
}

.menu-item {
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}

.menu-item:hover {
  background: #182231;
}

.menu-item.destructive {
  color: var(--danger);
}

.menu-item.destructive .icon {
  stroke: var(--danger);
}

.content {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  height: 100%;
}

.ring-panel {
  background: var(--panel-alt);
  border-radius: 22px;
  padding: 28px;
  display: grid;
  gap: 20px;
  align-content: start;
  animation: rise 0.6s ease both;
}

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

.ring-title {
  font-size: 18px;
  font-weight: 600;
}

.ring-wrap {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 12px 0;
}

#ringSvg {
  width: min(420px, 100%);
  height: auto;
}

.ring-track {
  fill: none;
  stroke: url(#trackGradient);
  stroke-width: var(--ring-width);
  stroke-linecap: round;
}

.ring-center {
  position: absolute;
  display: grid;
  place-items: center;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: #111a24;
  box-shadow: inset 0 0 0 1px var(--border), 0 12px 30px rgba(5, 12, 20, 0.55);
}

.total-time {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent-soft);
}

.total-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #121c28;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 14px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.legend-time {
  font-weight: 600;
  color: var(--text);
}

.entry-panel {
  background: var(--panel);
  border-radius: 22px;
  padding: 26px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 16px;
  box-shadow: inset 0 0 0 1px var(--border-strong);
  animation: rise 0.6s ease both;
  animation-delay: 0.08s;
}

.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entry-title {
  font-size: 18px;
  font-weight: 600;
}

.primary-btn,
.ghost-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(120deg, #2f94ff 0%, #29d2a0 100%);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(10, 24, 40, 0.55);
}

.ghost-btn {
  background: #1a2431;
  color: var(--text);
}

.entry-form {
  display: grid;
  gap: 12px;
  background: var(--panel-soft);
  padding: 16px;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px var(--border);
}

.form-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hidden {
  display: none;
}

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

.form-label {
  font-size: 13px;
  color: var(--muted);
}

.form-input {
  border: none;
  background: #0c131b;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.form-input.input-error {
  box-shadow: inset 0 0 0 1px rgba(255, 141, 141, 0.8);
}

.form-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #101826;
  box-shadow: inset 0 0 0 1px var(--border);
}

.entry-meta {
  display: grid;
  gap: 4px;
}

.entry-time {
  font-size: 14px;
  font-weight: 600;
}

.entry-duration {
  font-size: 12px;
  color: var(--muted);
}

.entry-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.entry-actions {
  display: flex;
  gap: 6px;
}

.entry-empty {
  padding: 12px 14px;
  border-radius: 14px;
  background: #101826;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--muted);
  font-size: 13px;
}

.history {
  overflow: auto;
  display: grid;
  gap: 12px;
  padding-right: 4px;
}

.history details {
  background: #0f1620;
  border-radius: 14px;
  padding: 12px 14px;
}

.history summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}

.history summary::-webkit-details-marker {
  display: none;
}

.history-date {
  color: var(--text);
}

.history-total {
  color: var(--muted);
  font-size: 13px;
}

.history-session {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 2px;
  border-top: 1px solid rgba(88, 106, 122, 0.45);
}

.tick-label {
  font-size: 11px;
  fill: #9aabbc;
}

.tick-dot {
  fill: #2b3948;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 10, 16, 0.68);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(420px, 92vw);
  background: #0f1620;
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-textarea {
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #0b121a;
  box-shadow: inset 0 0 0 1px var(--border);
  resize: vertical;
  min-height: 130px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.modal-status.success {
  color: var(--accent-soft);
}

.modal-status.error {
  color: var(--danger);
}

.duration-panel {
  width: min(520px, 94vw);
  gap: 16px;
}

.duration-body {
  display: grid;
  gap: 16px;
}

.duration-row {
  display: grid;
  gap: 10px;
}

.duration-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.duration-label {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #c3d2e4;
}

.duration-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.duration-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #182333;
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  touch-action: none;
}

.duration-track:focus-visible {
  outline: 2px solid rgba(83, 183, 255, 0.45);
  outline-offset: 4px;
}

.duration-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(83, 183, 255, 0.9), rgba(50, 214, 176, 0.95));
  pointer-events: none;
}

.duration-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #f3f8ff;
  border: 2px solid rgba(50, 214, 176, 0.9);
  box-shadow: 0 6px 16px rgba(5, 12, 20, 0.6);
  pointer-events: none;
}

.duration-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.duration-chip {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 12px;
  background: #101926;
  box-shadow: inset 0 0 0 1px var(--border);
  text-align: center;
}

.duration-chip.highlight {
  background: linear-gradient(130deg, rgba(83, 183, 255, 0.18), rgba(50, 214, 176, 0.18));
  box-shadow: inset 0 0 0 1px rgba(83, 183, 255, 0.25);
}

.duration-chip-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.duration-chip-value {
  font-size: 14px;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111a24;
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.form-input:focus,
.date-picker:focus,
.modal-textarea:focus {
  outline: 2px solid rgba(83, 183, 255, 0.45);
  outline-offset: 2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  .content {
    grid-template-columns: 1fr;
  }
  .ring-panel {
    order: 1;
  }
  .entry-panel {
    order: 2;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-right {
    justify-content: space-between;
  }
  .tabs {
    flex-wrap: wrap;
  }
  .top-actions {
    justify-content: flex-end;
  }
}
