:root {
  --ink: #1e2a24;
  --muted: #69736d;
  --paper: #f3efe7;
  --card: #fffdf8;
  --line: #ded8ce;
  --green: #193d2e;
  --lime: #c9ee65;
  --orange: #ef8354;
  --shadow: 0 24px 70px rgba(36, 47, 39, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.flash-layer { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; background: var(--flash-color, var(--lime)); }
.flash-layer.flashing { animation: flash .7s ease-out; }
@keyframes flash { 0%, 40% { opacity: .58; } 20%, 70% { opacity: .08; } 100% { opacity: 0; } }

.topbar { height: 76px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 6vw, 88px); position: relative; z-index: 2; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: .04em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 11px; letter-spacing: -.05em; }
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; background: #78a993; border-radius: 50%; box-shadow: 0 0 0 5px rgba(120,169,147,.12); }
.status-pill.running .status-dot { background: var(--lime); box-shadow: 0 0 0 5px rgba(201,238,101,.16); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.5); } }

.app-shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; padding: 76px 0 50px; position: relative; z-index: 1; }
.hero { display: grid; grid-template-columns: 1.45fr .7fr; align-items: end; gap: 60px; margin-bottom: 46px; }
.eyebrow { margin: 0 0 16px; font-size: 11px; letter-spacing: .22em; font-weight: 800; color: #6e7f76; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 6.7vw, 76px); line-height: .97; letter-spacing: -.055em; font-weight: 500; }
h1 em { color: var(--green); font-weight: inherit; }
.hero-copy { margin: 0 0 7px; color: var(--muted); line-height: 1.75; font-size: 14px; }

.timer-card { border-radius: 28px; padding: clamp(24px, 5vw, 52px); background: var(--green); color: white; box-shadow: var(--shadow); overflow: hidden; overflow: clip; position: relative; }
.timer-card::after { content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%; background: rgba(255,255,255,.035); right: -140px; top: -230px; }
.timer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.timer-label { font-size: 12px; color: rgba(255,255,255,.56); letter-spacing: .12em; }
.total-display { font-variant-numeric: tabular-nums; font-size: clamp(64px, 11vw, 116px); line-height: 1; letter-spacing: -.075em; font-weight: 700; margin: 7px 0 23px; }
.round-badge { min-width: 72px; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(255,255,255,.55); font-size: 10px; }
.round-badge strong { color: white; font-size: 19px; margin-top: 2px; }
.progress-track { height: 4px; border-radius: 5px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--lime); transition: width .2s linear; }
.segment-now { margin-top: 40px; padding: 27px 30px 23px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.055); border-radius: 18px; }
.segment-meta { display: flex; justify-content: space-between; color: rgba(255,255,255,.48); font-size: 11px; letter-spacing: .04em; }
.segment-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin: 22px 0; }
.current-name { margin: 0; color: var(--lime); font-size: clamp(26px, 4vw, 38px); font-weight: 750; letter-spacing: -.04em; }
.current-hint { margin: 6px 0 0; color: rgba(255,255,255,.44); font-size: 11px; }
.segment-display { font-variant-numeric: tabular-nums; font-size: clamp(42px, 7vw, 68px); line-height: .85; letter-spacing: -.055em; font-weight: 650; }
.segment-progress { height: 3px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.segment-progress div { height: 100%; width: 0; background: var(--segment-color, var(--orange)); transition: width .15s linear; }
.controls { display: flex; align-items: center; justify-content: center; gap: 13px; margin-top: 30px; }
.controls button { border: 0; cursor: pointer; transition: transform .2s, background .2s, opacity .2s; }
.controls button:hover:not(:disabled) { transform: translateY(-2px); }
.icon-btn { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.09); }
.icon-btn svg { width: 21px; fill: none; stroke: white; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.start-btn { min-width: 176px; height: 56px; padding: 0 27px; border-radius: 99px; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--lime); color: var(--green); font-weight: 800; }
.start-btn svg { width: 20px; fill: currentColor; stroke: none; }
.controls button:disabled { opacity: .32; cursor: not-allowed; }

.settings { margin-top: 64px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-heading h2 { font-family: Georgia, serif; margin: 0; font-size: 37px; letter-spacing: -.035em; font-weight: 500; }
.section-heading p:last-child { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.total-setting { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.total-setting > div:first-child { display: flex; align-items: center; gap: 16px; }
.setting-icon { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.4); }
.setting-icon svg { width: 20px; fill: none; stroke: var(--green); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.total-setting strong, .total-setting span { display: block; }
.total-setting strong { font-size: 14px; }
.total-setting div div span { margin-top: 6px; color: var(--muted); font-size: 11px; }
.time-inputs { display: flex; align-items: center; gap: 7px; }
.time-inputs i { font-style: normal; font-weight: 700; color: #89908b; }
.time-inputs label { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding-right: 11px; background: rgba(255,255,255,.55); }
.time-inputs input { width: 54px; border: 0; padding: 11px 3px 11px 12px; outline: 0; background: transparent; text-align: right; font-weight: 750; }
.time-inputs label span { color: var(--muted); font-size: 11px; }
.time-inputs label:focus-within { border-color: #739080; box-shadow: 0 0 0 3px rgba(44,82,62,.08); }

.segments-heading { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 14px; }
.segments-heading > div { display: flex; align-items: center; gap: 10px; }
.segments-heading strong { font-size: 14px; }
.segments-heading div span { color: var(--muted); font-size: 11px; padding: 3px 8px; background: #e6e1d8; border-radius: 20px; }
.add-btn { border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.add-btn span { display: inline-grid; width: 23px; height: 23px; margin-right: 5px; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 16px; }
.segments-list { display: grid; gap: 9px; }
.segment-item { display: grid; grid-template-columns: 26px 14px minmax(120px, 1fr) auto auto; gap: 15px; align-items: center; min-height: 82px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,248,.66); transition: opacity .2s, border .2s; }
.segment-item:focus-within { border-color: #9aaa9f; }
.drag-handle { color: #9b9d99; font-size: 20px; cursor: grab; text-align: center; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--item-color); box-shadow: 0 0 0 5px color-mix(in srgb, var(--item-color) 15%, transparent); }
.name-field > span, .duration-field > span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.segment-name { width: 100%; min-width: 0; border: 0; padding: 0; outline: 0; background: transparent; font-weight: 700; }
.duration-field { display: grid; grid-template-columns: 1fr 5px 1fr; align-items: center; column-gap: 4px; min-width: 150px; }
.duration-field > span { grid-column: 1 / -1; }
.duration-field label { display: flex; align-items: baseline; gap: 3px; }
.duration-field input { width: 43px; border: 0; border-bottom: 1px solid #cbc5ba; outline: 0; background: transparent; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.duration-field small { color: var(--muted); font-size: 9px; }
.duration-field b { font-size: 12px; color: var(--muted); }
.item-actions { display: flex; gap: 4px; }
.item-actions button { width: 29px; height: 29px; border: 0; border-radius: 8px; background: transparent; color: #7f8782; cursor: pointer; font-size: 15px; }
.item-actions button:hover:not(:disabled) { background: #e9e4da; color: var(--ink); }
.item-actions button:disabled { opacity: .25; cursor: not-allowed; }
.delete-segment { font-size: 20px !important; }
.settings.locked { opacity: .56; pointer-events: none; }

footer { text-align: center; padding: 16px 20px 34px; color: #929892; font-size: 10px; letter-spacing: .04em; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 20px); padding: 11px 16px; color: white; background: #24352c; border-radius: 9px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 10px 30px rgba(0,0,0,.16); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .topbar { height: 64px; }
  .app-shell { width: min(100% - 24px, 1080px); padding-top: 42px; }
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero-copy { max-width: 430px; }
  .timer-card { border-radius: 21px; }
  .segment-now { padding: 21px 18px; }
  .segment-main { gap: 15px; }
  .section-heading p:last-child { display: none; }
  .segment-item { grid-template-columns: 18px 10px 1fr auto; gap: 10px; padding: 15px 10px; }
  .duration-field { grid-column: 3 / 4; min-width: 0; }
  .item-actions { grid-row: 1 / 3; grid-column: 4; flex-direction: column; }
  .total-setting { align-items: flex-start; flex-direction: column; padding: 22px 0; }
}

@media (max-width: 430px) {
  h1 { font-size: 40px; }
  .total-display { font-size: 62px; }
  .segment-display { font-size: 42px; }
  .round-badge { min-width: 60px; }
  .current-name { font-size: 25px; }
  .start-btn { min-width: 155px; }
  .icon-btn { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
