:root {
  color-scheme: light;
  --paper: #f6f3ed;
  --surface: #fffdf9;
  --ink: #252826;
  --muted: #6f746e;
  --line: #dcd9d1;
  --green: #34765b;
  --green-dark: #285c47;
  --coral: #d86a50;
  --yellow: #e6b84f;
  --ring-length: 665.96;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(52, 118, 91, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 106, 80, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family:
    "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100% - 32px, 1080px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px 0 24px;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 34px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.settings-button {
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.settings-button:hover {
  color: var(--ink);
  border-color: #b9b7af;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 5px solid var(--green);
  border-right-color: var(--coral);
  border-radius: 50%;
}

.session-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.session-count strong {
  color: var(--ink);
  font-size: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.72fr);
  gap: 18px;
  align-items: stretch;
}

.timer-panel,
.task-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 18px 48px rgba(50, 48, 42, 0.08);
}

.timer-panel {
  padding: 28px clamp(20px, 6vw, 64px) 34px;
}

.mode-tabs {
  width: fit-content;
  margin: 0 auto 28px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #efede7;
}

.mode-tab {
  min-width: 86px;
  padding: 8px 18px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.mode-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(37, 40, 38, 0.12);
}

.timer-visual {
  position: relative;
  width: min(72vw, 310px);
  aspect-ratio: 1;
  margin: 0 auto 28px;
  display: grid;
  place-items: center;
}

.task-panel {
  min-height: 570px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
}

.task-header h2,
.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.task-count {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ece9e2;
  font-size: 13px;
  font-weight: 800;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  margin-bottom: 18px;
}

.task-form input {
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  background: white;
}

.task-form input:focus {
  border-color: var(--green);
}

.task-form button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-size: 22px;
}

.task-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.task-item {
  position: relative;
  min-height: 50px;
  padding: 8px 8px 8px 10px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  transition: transform 0.24s ease, opacity 0.24s ease, background 0.2s ease;
}

.task-item:hover {
  border-color: #c6c3bb;
}

.task-item.completing {
  overflow: visible;
  color: var(--green-dark);
  background: #e7f2eb;
  pointer-events: none;
  transform: scale(1.025);
}

.task-item.removing {
  opacity: 0;
  transform: translateX(24px) scale(0.94);
}

.complete-task,
.delete-task {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.complete-task {
  border: 2px solid #b9bdb8;
  border-radius: 50%;
  color: transparent;
  font-weight: 900;
}

.complete-task:hover {
  border-color: var(--green);
  color: var(--green);
}

.completing .complete-task {
  border-color: var(--green);
  background: var(--green);
  color: white;
  animation: task-pop 0.35s ease;
}

.task-text {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}

.delete-task {
  color: #a5a59f;
  font-size: 18px;
}

.delete-task:hover {
  color: var(--coral);
}

.celebration-dot {
  position: absolute;
  top: 50%;
  left: 25px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
  pointer-events: none;
  animation: celebrate 0.55s ease-out forwards;
}

.celebration-dot:nth-of-type(2n) {
  background: var(--yellow);
}

.celebration-dot:nth-of-type(3n) {
  background: var(--green);
}

.empty-tasks {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #9a9c97;
  text-align: center;
}

.empty-tasks span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px dashed #cccbc4;
  border-radius: 50%;
  font-size: 20px;
}

.empty-tasks p {
  margin: 10px 0 0;
  font-size: 13px;
}

.empty-tasks[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-dialog {
  width: min(calc(100% - 32px), 430px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(37, 40, 38, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(37, 40, 38, 0.42);
}

.settings-dialog form {
  padding: 26px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
}

.duration-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.duration-fields > label {
  padding: 14px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.number-field {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--ink);
}

.number-field input {
  width: 74px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
}

.setting-hint {
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
}

.save-settings-button {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.undo-toast {
  position: fixed;
  z-index: 20;
  bottom: 24px;
  left: 50%;
  min-width: min(360px, calc(100% - 32px));
  padding: 13px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.undo-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.undo-toast button {
  border: 0;
  background: transparent;
  color: #f3c85c;
  cursor: pointer;
  font-weight: 800;
}

.undo-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--yellow);
  transform-origin: left;
}

.show .undo-progress {
  animation: undo-countdown 5s linear forwards;
}

@keyframes task-pop {
  50% {
    transform: scale(1.25);
  }
}

@keyframes celebrate {
  to {
    opacity: 0;
    transform: translate(var(--burst-x), var(--burst-y)) scale(0.3);
  }
}

@keyframes undo-countdown {
  to {
    transform: scaleX(0);
  }
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 9;
}

.ring-track {
  stroke: #e5e3dc;
}

.ring-progress {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: var(--ring-length);
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s linear, stroke 0.2s ease;
}

.break-mode .ring-progress {
  stroke: var(--coral);
}

.time-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-content p,
.time-content span {
  margin: 0;
  color: var(--muted);
}

.time-content p {
  font-size: 14px;
  font-weight: 700;
}

.time-content time {
  margin: 7px 0 4px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: clamp(58px, 14vw, 78px);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
}

.time-content span {
  min-height: 21px;
  font-size: 13px;
}

.controls {
  display: grid;
  grid-template-columns: 48px minmax(150px, 190px) 48px;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.controls button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line) !important;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.icon-button:hover {
  color: var(--ink);
  background: #f0eee8;
}

.primary-button {
  height: 54px;
  border-radius: 7px;
  background: var(--green);
  color: white;
  font-weight: 700;
  box-shadow: 0 7px 0 var(--green-dark);
}

.primary-button:hover {
  filter: brightness(1.05);
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 var(--green-dark);
}

.break-mode .primary-button {
  background: var(--coral);
  box-shadow: 0 7px 0 #a94e39;
}

.play-icon {
  display: inline-block;
  margin-right: 8px;
  font-size: 12px;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

footer {
  margin-top: auto;
  padding-top: 26px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.site-footer nav {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.site-footer a,
.site-footer button {
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ad-slot {
  width: min(100%, 970px);
  min-height: 100px;
  margin: 140px auto 0;
  padding: 24px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.ad-slot:empty {
  display: none;
}

.ad-slot::before {
  content: "広告";
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.content-shell {
  width: min(100% - 32px, 780px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px 0 24px;
  display: flex;
  flex-direction: column;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 34px;
}

.back-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.content-document {
  padding: clamp(26px, 6vw, 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.96);
  box-shadow: 0 18px 48px rgba(50, 48, 42, 0.08);
}

.content-document > header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.content-document h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.3;
  letter-spacing: 0;
}

.content-document .lead {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.content-document section {
  padding-top: 26px;
}

.content-document h2 {
  margin: 0 0 10px;
  font-size: 19px;
  letter-spacing: 0;
}

.content-document h3 {
  margin: 20px 0 8px;
  font-size: 16px;
  letter-spacing: 0;
}

.content-document p,
.content-document li {
  color: #4f544f;
  font-size: 14px;
  line-height: 1.9;
}

.content-document p {
  margin: 8px 0;
}

.content-document ul,
.content-document ol {
  margin: 8px 0;
  padding-left: 1.5em;
}

.content-document a {
  color: var(--green-dark);
  text-underline-offset: 3px;
}

.updated-date {
  color: var(--muted);
  font-size: 12px;
}

.publication-placeholder {
  padding: 10px 12px;
  border-left: 3px solid var(--yellow);
  background: #fff8df;
  color: #665628 !important;
}

.document-footer {
  margin-top: 28px;
  text-align: right;
}

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

  .app-header {
    margin-bottom: 20px;
  }

  .header-actions {
    gap: 10px;
  }

  .settings-button span:last-child {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .timer-panel {
    padding: 22px 18px 28px;
  }

  .mode-tabs {
    margin-bottom: 20px;
  }

  .timer-visual {
    width: min(74vw, 280px);
    margin-bottom: 22px;
  }

  .controls {
    grid-template-columns: 44px minmax(132px, 1fr) 44px;
    gap: 10px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  footer {
    align-items: flex-start;
  }

  .site-footer {
    flex-direction: column;
  }

  .site-footer nav {
    justify-content: flex-start;
  }

  .ad-slot {
    margin-top: 96px;
  }

  .content-shell {
    width: min(100% - 20px, 780px);
    padding-top: 20px;
  }

  .content-header {
    margin-bottom: 20px;
  }

  .content-document {
    padding: 26px 20px;
  }

  .task-panel {
    min-height: 390px;
  }
}

@media (min-width: 521px) and (max-width: 840px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .task-panel {
    min-height: 400px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
