:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface-2: #050505;
  --surface-3: #0d0d0d;
  --line: #242424;
  --soft-white: #e6e6e6;
  --text: #f4f7f2;
  --muted: #8f8f8f;
  --accent: var(--soft-white);
  --accent-2: #ff735f;
  --blue: #7894ff;
  --shadow: none;
  --radius: 8px;
  font-family:
    Inter, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #000;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

.drive-pill {
  min-width: 158px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #000;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.drive-pill.is-connected {
  border-color: rgba(40, 214, 173, 0.5);
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.timer-stage,
.settings-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  box-shadow: var(--shadow);
}

.timer-stage {
  padding: clamp(14px, 3vw, 24px);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tab,
.quick-grid button,
.custom-time button,
.secondary-button,
.small-button,
.file-button {
  border-radius: var(--radius);
  font-weight: 900;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.tab.is-active {
  border-color: var(--accent);
  background: #000;
  color: var(--text);
}

.timer-face {
  position: relative;
  overflow: hidden;
  min-height: clamp(360px, 54vw, 590px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: clamp(18px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  color: #fff;
}

.timer-face::before {
  display: none;
}

.timer-meta,
.sub-display {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: clamp(12px, 1.7vw, 15px);
  font-weight: 900;
}

.timer-meta span {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #000;
}

.time-display {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 0.98em;
  contain: layout paint;
  overflow: hidden;
  color: var(--accent);
  font-family: "Arial Narrow", "Aptos Narrow", "Bahnschrift Condensed",
    "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(132px, 20vw, 270px);
  font-stretch: condensed;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  filter: none;
}

.time-text {
  display: inline-block;
  --time-fit-scale: 1;
  transform: scaleX(0.76) scale(var(--time-fit-scale));
  transform-origin: center;
}

.sr-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.seg-digit {
  position: relative;
  display: inline-block;
  width: 0.56em;
  height: 1em;
}

.seg {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.07;
}

.seg.is-on {
  opacity: 1;
}

.seg-a,
.seg-d,
.seg-g {
  left: 0.12em;
  width: 0.32em;
  height: 0.075em;
}

.seg-a {
  top: 0.02em;
}

.seg-g {
  top: 0.462em;
}

.seg-d {
  bottom: 0.02em;
}

.seg-b,
.seg-c,
.seg-e,
.seg-f {
  width: 0.075em;
  height: 0.36em;
}

.seg-b,
.seg-c {
  right: 0.04em;
}

.seg-f,
.seg-e {
  left: 0.04em;
}

.seg-b,
.seg-f {
  top: 0.08em;
}

.seg-c,
.seg-e {
  bottom: 0.08em;
}

.seg-colon {
  position: relative;
  display: inline-block;
  width: 0.16em;
  height: 1em;
}

.seg-colon::before,
.seg-colon::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0.08em;
  height: 0.08em;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.seg-colon::before {
  top: 0.31em;
}

.seg-colon::after {
  bottom: 0.31em;
}

.primary-controls {
  display: grid;
  grid-template-columns: 58px minmax(170px, 300px) 58px;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
}

.icon-button,
.start-button {
  min-height: 58px;
  border-radius: var(--radius);
}

.icon-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
}

.icon-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.start-button {
  background: var(--accent);
  color: #000;
  font-size: 20px;
  font-weight: 950;
}

.start-button.is-running {
  background: var(--accent-2);
  color: #fff;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.quick-grid button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.quick-grid button.is-selected {
  border-color: var(--accent);
  background: #000;
  color: var(--text);
}

.custom-time {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 96px;
  gap: 8px;
}

.custom-time label,
.number-grid label,
.slider-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.custom-time input,
.number-grid input,
.text-input,
.select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.custom-time input:focus,
.number-grid input:focus,
.text-input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(40, 214, 173, 0.13);
}

.custom-time button {
  align-self: end;
  min-height: 42px;
  background: var(--blue);
  color: #fff;
}

.settings-panel {
  padding: 14px;
}

.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section:first-child {
  padding-top: 4px;
}

.panel-section:last-child {
  border-bottom: 0;
  padding-bottom: 4px;
}

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

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.wide-toggle {
  margin-top: 12px;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.small-button,
.secondary-button,
.file-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
}

.small-button {
  background: var(--accent);
  color: #000;
  border-color: transparent;
}

.small-button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.audio-row,
.drive-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.slider-label {
  margin-top: 12px;
}

.slider-label input {
  width: 100%;
  accent-color: var(--accent);
}

.text-input {
  min-height: 40px;
}

.secondary-button {
  width: 100%;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
}

.stats span {
  display: block;
  font-size: 26px;
  font-weight: 950;
  line-height: 1;
}

.stats small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.history-list time {
  color: var(--muted);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

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

  .settings-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
  }

  .panel-section:nth-last-child(2) {
    border-bottom: 0;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .drive-pill {
    width: 100%;
  }

  .mode-tabs,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .timer-face {
    min-height: 330px;
    padding: 20px 12px;
  }

  .timer-face::before {
    inset: 12px;
  }

  .timer-meta {
    flex-wrap: wrap;
  }

  .time-display {
    font-size: clamp(178px, 64vw, 260px);
  }

  .primary-controls {
    grid-template-columns: 52px 1fr 52px;
  }

  .custom-time,
  .settings-panel,
  .number-grid {
    grid-template-columns: 1fr;
  }
}
