/* Variables */
:root {
  --sand:        #ede8df;
  --white:       #ffffff;
  --ink:         #1a1917;
  --muted:       #7a766f;
  --border:      #e8e3da;
  --accent:      #c94040;
  --accent-dark: #a83030;
  --accent-light:#faeaea;
  --green:       #2d9e6b;
  --amber:       #c97a12;
  --radius:      18px;
  --shadow:      0 1px 3px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.07);

  --font-display: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background-color: var(--sand);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */

header {
  display: flex;
  align-items: center;
  padding: 20px 48px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
}

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

.logo { font-size: 1.3rem; display: inline-flex; align-items: center; }

header h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* Main layout */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 52px 48px 88px;
  display: flex;
  flex-direction: column;
  gap: 52px;
}

/* Timer section, full width */

.timer-section {
  width: 100%;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 48px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 52px;
}

.timer-left {
  flex-shrink: 0;
}

.timer-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
}

.timer-eyebrow {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--muted);
}

/* Timer ring */
.timer-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}

#timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 5;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.95s linear, stroke 0.4s;
}

.ring-progress.paused { stroke: var(--amber); }

.timer-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Settings row */
.settings-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--white);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a766f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color 0.2s;
}
select:focus    { border-color: var(--accent); }
select:disabled { opacity: 0.5; }

/* Tag chips */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 42px;
  cursor: text;
  transition: border-color 0.2s;
  background: var(--white);
}
.tags-wrap:focus-within { border-color: var(--accent); }

.chips { display: contents; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 500;
}

.chip button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--accent);
  line-height: 1;
  padding: 0 1px;
  opacity: 0.7;
}
.chip button:hover { opacity: 1; }

.tags-wrap input {
  border: none;
  outline: none;
  font-size: 0.88rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: transparent;
  min-width: 80px;
  flex: 1;
}
.tags-wrap input:disabled { opacity: 0; pointer-events: none; }

/* Controls */

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
}

.btn {
  border: none;
  border-radius: 100px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active   { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Start: large and commanding */
#btn-start {
  padding: 14px 56px;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  background: var(--ink);
  color: var(--white);
}
#btn-start:hover:not(:disabled) { opacity: 0.82; }

/* Pause/Resume: standard size, same ink fill */
#btn-pause {
  padding: 11px 32px;
  font-size: 0.88rem;
  background: var(--ink);
  color: var(--white);
}
#btn-pause:hover:not(:disabled) { opacity: 0.82; }

/* Done: ghost style, lower visual weight so it's not accidentally pressed */
#btn-done {
  padding: 10px 24px;
  font-size: 0.82rem;
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
}
#btn-done:hover:not(:disabled) {
  background: var(--green);
  color: var(--white);
}

/* Generic fallback classes used by modal submit */
.btn.primary  { background: var(--ink);   color: var(--white); padding: 12px 36px; }
.btn.secondary { background: var(--border); color: var(--ink);   padding: 12px 36px; }
.btn.success  { background: var(--green); color: var(--white); padding: 12px 36px; }

/* Bottom grid */

.bottom-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 48px;
  align-items: start;
}

/* Shared section head */
.section-head {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--ink);
}

/* Statistics section */

.stats-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fbtn {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--white);
  color: var(--muted);
  font-size: 0.76rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.fbtn:hover  { border-color: var(--accent); color: var(--accent); }
.fbtn.active { background: var(--ink); border-color: var(--ink); color: var(--white); }

.stats-sublabel {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: -6px;
}

/* Summary stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 300;
  color: var(--ink);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

/* Bar chart */
.chart-wrap {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 16px 12px;
}

#stats-chart {
  display: block;
  width: 100%;
  height: auto;
}

.sbar.active       { fill: var(--accent); opacity: 0.65; }
.sbar.active:hover { opacity: 1; }
.sbar.today        { fill: var(--accent); opacity: 1; }
.sbar.today-empty  { fill: var(--border); opacity: 0.6; }
.sbar.empty        { fill: var(--border); }

.grid-line { stroke: var(--border); stroke-width: 0.5; }
.grid-base { stroke: var(--border); stroke-width: 1; }

.chart-label {
  font-size: 8.5px;
  fill: var(--muted);
  font-family: var(--font-body);
}

.bar-label {
  font-size: 8px;
  fill: var(--muted);
  font-family: var(--font-body);
}

.today-label {
  fill: var(--accent);
  font-weight: 600;
}

/* History section */

.history-section {
  display: flex;
  flex-direction: column;
}

.sessions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-card {
  background: var(--white);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.sinfo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.smeta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sdur, .sdate {
  font-size: 0.76rem;
  color: var(--muted);
}

.sbadge {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.s-completed   { background: #d5f5e9; color: #1a7347; }
.s-in_progress { background: var(--accent-light); color: var(--accent-dark); }
.s-paused      { background: #fef5e4; color: #9a5c06; }

.stags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.stag {
  background: #f0ece6;
  color: var(--muted);
  border-radius: 100px;
  padding: 1px 10px;
  font-size: 0.7rem;
}

.del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 6px 8px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  opacity: 0.5;
}
.del:hover { color: var(--accent); background: var(--accent-light); opacity: 1; }

/* Empty state */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 48px 0;
}

/* Header: logged-in user and logout */

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-user[hidden] { display: none; }

.header-username {
  font-size: 0.84rem;
  color: var(--muted);
}

.btn-logout,
.btn-login {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover,
.btn-login:hover { border-color: var(--accent); color: var(--accent); }

.btn-delete-account {
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: 0.75rem;
  font-family: var(--font-body);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-delete-account:hover { color: #c0392b; opacity: 1; }

/* Save prompt (shown after guest session completes) */

.save-prompt {
  font-size: 0.84rem;
  color: var(--muted);
  background: var(--sand);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
}

.save-prompt-login {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.save-prompt-login:hover { color: var(--accent-dark); }

/* Auth modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 23, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  background: var(--white);
  border-radius: 22px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.2);
  padding: 48px 44px 40px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.modal-logo { font-size: 2.2rem; display: flex; justify-content: center; }

.modal-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-top: -8px;
}

.modal-tabs {
  display: flex;
  width: 100%;
  background: var(--sand);
  border-radius: 100px;
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: transparent;
  border-radius: 100px;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.tab-btn:not(.active):hover { color: var(--ink); }

#auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-field label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

.form-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.form-field input:focus { border-color: var(--accent); }

.password-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 4px 0 0;
}

.auth-error {
  font-size: 0.82rem;
  color: var(--accent);
  min-height: 1.2em;
  text-align: center;
}

.auth-submit {
  width: 100%;
  padding: 13px;
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: 100px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth-submit:hover { opacity: 0.82; }
.auth-submit:disabled { opacity: 0.45; cursor: not-allowed; }

.header-guest {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-guest[hidden] { display: none; }

.btn-demo-header {
  background: var(--accent-light);
  border: 1.5px solid transparent;
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-demo-header:hover { border-color: var(--accent); }

/* Footer */

footer {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding: 0 48px 36px;
}

.footer-link {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--ink); }

/* Legal subpages */

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 52px 48px 88px;
}

.legal-page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 48px;
  transition: color 0.15s;
}
.legal-page-back:hover { color: var(--ink); }

.legal-page h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-bottom: 40px;
}

.legal-page h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 32px;
  margin-bottom: 8px;
}

.legal-page p {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 8px;
}

.legal-page a {
  color: var(--ink);
  text-underline-offset: 2px;
}

/* Responsive */

@media (max-width: 900px) {
  header  { padding: 18px 28px; }
  main    { padding: 40px 28px 72px; gap: 40px; }
  footer { padding: 0 28px 28px; }

  .bottom-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 640px) {
  .card {
    flex-direction: column;
    align-items: center;
    padding: 36px 24px 32px;
    gap: 24px;
  }

  .timer-right { align-items: center; }
  .controls    { justify-content: center; }
  .settings-row { max-width: 400px; }
}

@media (max-width: 560px) {
  header  { padding: 16px 20px; }
  main    { padding: 28px 16px 60px; gap: 32px; }
  footer { padding: 0 20px 24px; }
  .legal-page { padding: 36px 20px 60px; }

  .timer-wrap  { width: 170px; height: 170px; }
  .timer-time  { font-size: 3rem; }

  .settings-row { flex-direction: column; gap: 14px; }

  #btn-start   { padding: 13px 44px; }

  .section-head h2  { font-size: 1.8rem; }
  .stat-value { font-size: 1.8rem; }
}

@media (max-width: 420px) {
  .bar-label { display: none; }
}
