:root {
  color-scheme: light;
  --accent: #2196F3;
  --accent-hover: #1976D2;
  --warn: #FF9800;
  --warn-hover: #F57C00;
  --danger: #F44336;
  --danger-hover: #D32F2F;
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --card-bg-finished: #ffe4e2;
  --fg: #1a1a1a;
  --fg-muted: #5a5a5a;
  --border: #e4e4e2;
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.app-header h1 { font-size: 1rem; margin: 0; font-weight: 500; color: var(--fg-muted); }
.app-header .back { color: var(--fg); text-decoration: none; font-size: .9rem; }
.app-header .back:hover { color: var(--accent); }

.hero {
  min-height: calc(100svh - 50px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.hero .timer-container {
  width: 100%;
  max-width: 600px;
  margin: 0;
}

.app-wrapper {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.timer-container {
  background: var(--card-bg);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  padding: 32px;
  text-align: center;
  margin-bottom: 20px;
  transition: background-color .3s ease;
}
.timer-container.finished { background: var(--card-bg-finished); }

.timer-display {
  font-size: 5.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-radius: 50px;
  transition: background-color .2s, transform .1s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(.97); }
button.show-settings { background: var(--warn); }
button.show-settings:hover { background: var(--warn-hover); }

.settings { display: none; margin-top: 24px; text-align: left; }
.settings.open { display: block; }

.slider-container {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
}
.slider-label { min-width: 28px; font-weight: 700; color: var(--fg-muted); }
.slider-value { min-width: 28px; text-align: right; font-weight: 700; color: var(--accent); }
.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 5px;
  background: #ddd;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  font-weight: 600;
}
.switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle {
  position: absolute;
  inset: 0;
  background: #ccc;
  transition: .3s;
  border-radius: 34px;
  cursor: pointer;
}
.slider-toggle::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background: #fff;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider-toggle { background: var(--accent); }
input:checked + .slider-toggle::before { transform: translateX(26px); }

.history-container {
  background: var(--card-bg);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  padding: 20px;
  margin-bottom: 20px;
}
.history-container[hidden] { display: none; }
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.history-header h2 { margin: 0; color: var(--accent); font-size: 1.3rem; }
.history-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
}
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.history-list li:hover { color: var(--accent); }
.history-list li:last-child { border-bottom: none; }
.history-list button {
  background: var(--danger);
  padding: 6px 14px;
  font-size: .85rem;
}
.history-list button:hover { background: var(--danger-hover); }

.show-history {
  display: block;
  margin: 0 auto 40px;
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 10px 22px;
}
.show-history:hover { background: var(--accent); color: #fff; }

.wp-content {
  max-width: 640px;
  margin: 40px auto 0;
  padding: 0 4px;
  color: var(--fg-muted);
  line-height: 1.9;
}
.wp-content h2 {
  font-size: 1.15rem;
  color: var(--fg);
  margin: 32px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.wp-content h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.wp-content p { margin: 0 0 12px; }
.wp-content ul { padding-left: 1.4em; margin: 0 0 14px; }
.wp-content li { margin-bottom: 4px; }
.wp-content .note { font-size: .85rem; opacity: .8; }

@media (max-width: 520px) {
  .timer-display { font-size: 3.8rem; }
  button { padding: 12px 20px; font-size: .95rem; }
  .hero { padding: 24px 16px; }
  .app-wrapper { padding: 16px 16px 40px; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --card-bg: #1d1d1d;
  --card-bg-finished: #3a1f1f;
  --fg: #f0f0f0;
  --fg-muted: #a0a0a0;
  --border: #2a2a2a;
  --accent: #5a82ff;
  --accent-hover: #2a5bff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121212;
    --card-bg: #1d1d1d;
    --card-bg-finished: #3a1f1f;
    --fg: #f0f0f0;
    --fg-muted: #a0a0a0;
    --border: #2a2a2a;
    --accent: #5a82ff;
    --accent-hover: #2a5bff;
  }
}

.owt-theme-toggle {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(127, 127, 127, 0.4);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.owt-theme-toggle:hover { transform: translateY(-1px); border-color: rgba(127, 127, 127, 0.7); }
.owt-theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
:root[data-theme="dark"] .owt-theme-toggle {
  background: rgba(40, 40, 40, 0.85);
  color: #eee;
  border-color: rgba(200, 200, 200, 0.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .owt-theme-toggle {
    background: rgba(40, 40, 40, 0.85);
    color: #eee;
    border-color: rgba(200, 200, 200, 0.25);
  }
}
@media print { .owt-theme-toggle { display: none; } }

