:root {
  --ink: #1d292f;
  --muted: #6d7a80;
  --line: #dce3e5;
  --paper: #f8faf9;
  --panel: #ffffff;
  --blue: #1976ad;
  --orange: #f28b39;
  --yellow: #f5d964;
  --pink: #eaa0b4;
  --green: #b7d58f;
  --sky: #aadce2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }

.tool-shell { width: min(1440px, 100%); min-height: 100svh; margin: 0 auto; padding: 16px 30px 10px; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 9px; }
.eyebrow { margin: 0 0 7px; color: var(--orange); font-size: .76rem; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(1.45rem, 2.2vw, 2.1rem); line-height: 1.06; letter-spacing: -.045em; }
.intro { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.brand-mark { color: var(--ink); font-size: 1.18rem; font-weight: 850; letter-spacing: -.08em; }
.brand-mark span { color: var(--orange); font-weight: 700; }
.fullscreen-button { min-height: 38px; border: 1px solid var(--line); border-radius: 5px; padding: 7px 12px; color: var(--ink); background: #fff; font-size: .82rem; font-weight: 750; }
.fullscreen-button:hover { border-color: #aebdc1; background: #f4f8f8; }

.workspace { min-height: 0; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 6px 10px 10px; border: 1px solid var(--line); background: #fff; overflow: hidden; }
.clock-stage { width: min(1080px, 100%); display: grid; grid-template-columns: minmax(340px, 1.15fr) minmax(260px, .7fr); grid-template-rows: auto auto; align-items: center; gap: 0 clamp(18px, 4vw, 72px); transition: grid-template-columns .25s ease, gap .25s ease; }
.display-card { min-width: 0; text-align: center; }
.display-label { margin: 0 0 7px; color: #869298; font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.analog-card { grid-column: 1; grid-row: 1 / span 2; }
.digital-card { grid-column: 2; grid-row: 1; align-self: center; padding: 10px 18px 12px; border-left: 1px solid var(--line); }
.written-card { grid-column: 2; grid-row: 2; align-self: start; padding: 6px 18px 10px; border-left: 1px solid var(--line); }
.analog-wrap { position: relative; width: min(100%, 500px, 52vh); margin: 0 auto; }
.clock-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: none; }
.clock-face-shadow { fill: #fff; }
.clock-face { fill: #fff; stroke: #f0f3f3; stroke-width: 2; }
.clock-inner-ring { fill: none; stroke: #edf1f1; stroke-width: 4; }
.clock-center { fill: var(--ink); }
.clock-number { fill: var(--ink); font-size: 35px; font-weight: 550; text-anchor: middle; dominant-baseline: central; user-select: none; }
.tick { stroke: #bdc9cc; stroke-linecap: round; }
.tick.major { stroke: var(--ink); stroke-width: 3.5; }
.tick.minor { stroke-width: 1.6; }
.minute-mark { fill: #849297; font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.minute-mark-dot { fill: #d7e0e1; }
.hour-hand, .minute-hand, .second-hand { stroke-linecap: round; cursor: grab; }
.hour-hand:active, .minute-hand:active, .second-hand:active { cursor: grabbing; }
.hour-hand { stroke: var(--blue); stroke-width: 13; }
.minute-hand { stroke: var(--orange); stroke-width: 9; }
.second-hand { stroke: #3d9489; stroke-width: 3; }
.hand-cap { fill: var(--ink); }
.outer-sector { stroke: #fff; stroke-width: 2; }
.outer-time { fill: var(--ink); font-size: 15px; font-weight: 750; text-anchor: middle; dominant-baseline: central; }
.inner-part { fill: #111b20; font-size: 14px; font-weight: 850; letter-spacing: .08em; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.inner-sector { opacity: .17; }
.clock-svg.no-color .outer-sector { fill: #edf2f2 !important; }
.clock-svg.no-color .inner-part { fill: #111b20; }
.clock-svg.no-color .inner-sector { opacity: .035; }
.drag-hint { margin: 2px 0 0; color: #9aa5a8; font-size: .72rem; text-align: center; white-space: nowrap; pointer-events: none; }
.written-time { min-height: 38px; color: var(--ink); font-size: clamp(1.3rem, 2.1vw, 1.75rem); font-weight: 750; letter-spacing: -.03em; }
.digital-time-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.digital-time { width: 100%; border: 0; outline: none; background: transparent; color: var(--ink); font-size: clamp(3.3rem, 6vw, 6rem); font-weight: 780; letter-spacing: -.09em; text-align: center; line-height: .98; cursor: text; }
.digital-time:focus { color: var(--blue); }
.digital-helper { max-width: 260px; margin: 22px auto 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.digital-card, .written-card { transform: translateX(24px); }

.controls { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1.15fr 1fr 1.2fr; gap: 10px; margin-top: 8px; padding-top: 8px; background: var(--paper); }
.control-column { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); background: var(--panel); }
.control-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; color: var(--ink); font-size: .82rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.current-readout { color: var(--blue); font-size: 1.15rem; letter-spacing: -.03em; }
.control-row, .mode-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-row { margin-top: 12px; }
.primary-button, .secondary-button, .mode-button { min-height: 40px; border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px; color: var(--ink); background: #fff; font-size: .87rem; font-weight: 750; }
.primary-button { border-color: var(--blue); color: #fff; background: var(--blue); }
.primary-button:hover { background: #155d88; }
.secondary-button:hover, .mode-button:hover { border-color: #aebdc1; background: #f6f9f9; }
.play-icon { margin-right: 5px; font-size: .74rem; }
.mode-button { min-height: 34px; padding: 6px 10px; color: var(--muted); font-size: .78rem; }
.mode-button.active { border-color: var(--ink); color: var(--ink); background: #f0f4f4; }
.switch-grid { display: grid; gap: 11px; }
.switch-label { display: flex; align-items: center; gap: 9px; color: #526167; font-size: .87rem; line-height: 1.25; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.fake-switch { position: relative; flex: 0 0 auto; width: 33px; height: 20px; border-radius: 99px; background: #dbe3e4; transition: background .2s ease; }
.fake-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s ease; box-shadow: 0 1px 3px #17303922; }
.switch-label input:checked + .fake-switch { background: var(--blue); }
.switch-label input:checked + .fake-switch::after { transform: translateX(13px); }
.switch-label input:focus-visible + .fake-switch { outline: 3px solid #acd4e8; outline-offset: 2px; }
.control-tip { margin: 15px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.footer-note { padding-top: 14px; color: #7a888d; font-size: .77rem; text-align: center; }

.clock-stage.only-analog { grid-template-columns: minmax(360px, 650px); justify-content: center; }
.clock-stage.only-analog .analog-card { grid-column: 1; }
.clock-stage.only-analog .digital-card { display: none; }
.clock-stage.only-analog .written-card { grid-column: 1; grid-row: 2; border-left: 0; }
.clock-stage.no-analog { grid-template-columns: minmax(260px, 500px); justify-content: center; }
.clock-stage.no-analog .analog-card { display: none; }
.clock-stage.no-analog .digital-card { grid-column: 1; border-left: 0; }
.clock-stage.no-analog .written-card { grid-column: 1; grid-row: 2; border-left: 0; }
.clock-stage.only-digital { grid-template-columns: minmax(260px, 500px); justify-content: center; }
.clock-stage.only-digital .analog-card { display: none; }
.clock-stage.only-digital .digital-card { grid-column: 1; border-left: 0; }
.clock-stage.only-digital .written-card { grid-column: 1; grid-row: 2; border-left: 0; }
.clock-stage.only-text { grid-template-columns: minmax(260px, 500px); justify-content: center; }
.clock-stage.only-text .analog-card { display: block; }
.clock-stage.only-text .digital-card { display: none; }
.clock-stage.only-text .written-card { grid-column: 1; grid-row: 1; border-left: 0; }
.clock-stage.no-digital .analog-card { grid-column: 1; grid-row: 1; }
.clock-stage.no-digital { grid-template-columns: minmax(360px, 650px); justify-content: center; }
.clock-stage.no-digital .digital-card { display: none; }
.clock-stage.no-digital .written-card { grid-column: 1; grid-row: 2; border-left: 0; }
.clock-stage.no-text .written-card { display: none; }
.clock-stage.only-text .written-card { grid-row: 1; }

@media (max-width: 980px) {
  .tool-shell { padding: 14px 18px 8px; }
  .workspace { min-height: 0; padding: 8px 8px 12px; }
  .clock-stage { grid-template-columns: minmax(320px, 1fr) minmax(220px, .7fr); gap: 20px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .time-controls { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .tool-shell { min-height: auto; padding: 16px 12px 12px; }
  .topbar { align-items: flex-start; margin-bottom: 10px; }
  .brand-mark { font-size: 1rem; }
  .intro { font-size: .9rem; }
  .topbar-actions { gap: 8px; }
  .fullscreen-button { padding: 7px 9px; }
  .fullscreen-button span { display: none; }
  .workspace { padding-inline: 3px; }
  .clock-stage, .clock-stage.no-analog, .clock-stage.only-analog, .clock-stage.only-digital, .clock-stage.only-text, .clock-stage.no-digital { display: flex; flex-direction: column; gap: 8px; width: min(100%, 510px); }
  .analog-card, .digital-card, .written-card { width: 100%; border-left: 0; }
  .digital-card, .written-card { transform: none; }
  .digital-card { padding: 12px 14px 20px; }
  .written-card { order: 3; padding-top: 2px; }
  .controls { grid-template-columns: 1fr; }
  .time-controls { grid-column: auto; }
  .control-column { padding: 13px 14px; }
  .drag-hint { font-size: .65rem; }
}

@media (min-width: 701px) {
  :fullscreen .tool-shell { width: 100vw; height: 100vh; padding: 14px 26px 8px; }
  :fullscreen .analog-wrap { width: min(100%, 560px, 68vh); }
  :fullscreen .workspace { min-height: 0; }
}

@media print {
  .controls, .footer-note, .topbar .intro, .drag-hint, .digital-helper { display: none; }
  .tool-shell { padding: 0; }
  .workspace { border: 0; }
}
