:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --border: #e5e7eb;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
}

nav { display: flex; gap: 4px; flex-wrap: wrap; }

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.87rem;
  padding: 6px 10px;
  border-radius: 8px;
}

nav a:hover, nav a.active { background: var(--accent-soft); color: var(--accent); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 44px;
}

h1 { font-size: 1.25rem; margin-bottom: 6px; }
.subtitle { color: var(--muted); margin-bottom: 16px; font-size: 0.85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 5px; }

input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

textarea { min-height: 150px; resize: vertical; }

.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

button.primary:hover { background: #1d4ed8; }

.result {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 18px;
  margin-top: 18px;
  font-size: 1rem;
}

.result strong { color: var(--accent); font-size: 1.2rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stat {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.stat .num { font-size: 1.15rem; font-weight: 800; color: var(--accent); }
.stat .label { font-size: 0.8rem; color: var(--muted); }

table.detail {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.92rem;
}

table.detail th, table.detail td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.detail td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s, transform 0.15s;
  display: block;
}

.tool-card:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.tool-card .emoji { font-size: 1.5rem; }
.tool-card h2 { font-size: 0.95rem; margin: 8px 0 4px; }
.tool-card p { font-size: 0.8rem; color: var(--muted); }

.content { font-size: 0.88rem; }
.content h2 { font-size: 1.02rem; margin: 20px 0 8px; }
.content p { margin-bottom: 12px; color: #374151; }
.content ul { margin: 0 0 12px 20px; color: #374151; }

.timer-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 8px auto 20px;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 10;
}

.timer-ring .ring-bg { stroke: var(--border); }

.timer-ring .ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear;
}

.timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.timer-wrap.done .timer-display { color: #dc2626; }
.timer-wrap.done .ring-progress { stroke: #dc2626; }

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

button.ghost:hover { color: var(--text); border-color: var(--muted); }

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}

.preset-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.preset-chip:hover { background: #dbe7fd; }
.preset-chip.active { background: var(--accent); color: #fff; }

.custom-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}

.custom-time input {
  width: 56px;
  text-align: center;
  padding: 8px 4px;
}

.custom-time span { color: var(--muted); font-size: 0.85rem; }

.tab-bar {
  display: flex;
  gap: 6px;
  background: var(--accent-soft);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.tab-btn {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.tab-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }
.list-row .time { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.list-row .sub { font-size: 0.78rem; color: var(--muted); }
.list-row .del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}
.list-row .del:hover { color: #dc2626; }

.empty-hint { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 16px 0; }

.stopwatch-display {
  font-size: 2.6rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin: 24px 0 20px;
}

.lap-list { max-height: 220px; overflow-y: auto; margin-top: 4px; }
.lap-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.lap-row:last-child { border-bottom: none; }
.lap-row .lap-num { color: var(--muted); }

.calc-card { background: #1c1c1e; border-radius: 16px; padding: 16px; }
.calc-display {
  color: #fff;
  text-align: right;
  font-size: 3.4rem;
  font-weight: 400;
  padding: 24px 10px 6px;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}
.calc-sub { color: #8e8e93; text-align: right; font-size: 1.1rem; padding: 0 10px; min-height: 26px; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.calc-btn {
  border: none;
  border-radius: 999px;
  aspect-ratio: 1;
  font-size: 1.7rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.calc-btn.num { background: #333336; color: #fff; }
.calc-btn.fn { background: #a5a5a5; color: #000; }
.calc-btn.op { background: #ff9f0a; color: #fff; font-size: 2rem; }
.calc-btn.op.selected { background: #fff; color: #ff9f0a; }
.calc-btn.zero {
  grid-column: span 2;
  border-radius: 35px;
  aspect-ratio: auto;
  text-align: left;
  padding-left: 26px;
}


footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

footer a { color: var(--muted); }

@media (max-width: 600px) {
  h1 { font-size: 1.3rem; }
  .card { padding: 18px; }
}
