/* timer.css */
:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.88);
  --panel-2: rgba(2, 6, 23, 0.72);
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --ok: #22c55e;
  --warn: #ef4444;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 45%, #020617 100%);
  color: var(--text);
  min-height: 100%;
}

body {
  padding: 16px;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.card-header {
  padding: 24px 24px 8px;
}

.card-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
}

.card-title-small {
  font-size: 24px;
}

.card-subtitle {
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.card-body {
  padding: 24px;
}

.hero {
  background: var(--panel-2);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 26px;
  padding: 24px;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.hero.flash {
  transform: scale(1.01);
  border-color: rgba(245, 158, 11, 0.65);
}

.hero.complete {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(127, 29, 29, 0.26);
}

.hero-top {
  margin-bottom: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.stats-grid .stat-card:last-child {
  grid-column: 1 / -1;
}

.stat-card {
  min-width: 0;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.10);
  border-radius: 18px;
  padding: 16px;
}

.stat-card-wide {
  padding-top: 18px;
  padding-bottom: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.time-main {
  font-size: clamp(36px, 3.2vw, 52px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-secondary {
  font-size: clamp(22px, 2.1vw, 32px);
  font-weight: 700;
  color: var(--ok);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-secondary.warn {
  color: var(--warn);
}

.segment-name {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  word-break: break-word;
}

.segment-sub {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
}

#clockTime {
  white-space: nowrap;
}

.progress-wrap {
  margin-top: 24px;
}

.progress-bar {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.8);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
  transition: width 0.3s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

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

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

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: #f59e0b;
  color: #111827;
}

.btn-secondary {
  background: #334155;
  color: white;
}

.btn-soft {
  background: rgba(51, 65, 85, 0.55);
  color: white;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.segments-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.segment-item {
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.4);
  padding: 16px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.segment-item.current {
  border-color: rgba(245, 158, 11, 0.8);
  background: rgba(245, 158, 11, 0.12);
}

.segment-item.done {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}

.segment-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.segment-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
}

.segment-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.segment-duration {
  text-align: right;
  font-weight: 700;
  font-size: 22px;
}

.segment-status {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.editor-list {
  display: grid;
  gap: 14px;
}

.editor-item {
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.42);
  padding: 16px;
}

.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

input:focus {
  border-color: rgba(245, 158, 11, 0.7);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.summary-box {
  margin-top: 16px;
  border-radius: 20px;
  padding: 18px;
  background: rgba(2, 6, 23, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.summary-time {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0;
}

.summary-time.good {
  color: var(--ok);
}

.summary-time.off {
  color: var(--accent);
}

.summary-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.summary-note-spacing {
  margin-top: 6px;
}

.top-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.settings-box {
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.42);
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.settings-box .field {
  min-width: 0;
  margin-bottom: 0;
}

input,
textarea,
select {
  min-width: 0;
  max-width: 100%;
}

input[type="time"],
input[type="number"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

.top-actions-wrap {
  flex-wrap: wrap;
}

textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  resize: vertical;
  min-height: 140px;
  font-family: inherit;
}

textarea:focus {
  border-color: rgba(245, 158, 11, 0.7);
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.editor-header-main {
  flex: 1;
  min-width: 0;
}

.editor-header-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}

.editor-header-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.toggle-segment-btn {
  flex: 0 0 auto;
}

.editor-content {
  margin-top: 14px;
}

.editor-item.is-collapsed .editor-content {
  display: none;
}

.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.settings-panel-headline {
  flex: 1;
  min-width: 0;
}

.panel-collapsed {
  display: none;
}

.endtime-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.endtime-name {
  color: var(--muted);
  font-size: 13px;
}

.endtime-value {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .settings-panel-header {
    flex-direction: column;
    align-items: stretch;
  }
}

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

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    padding: 10px;
  }

  .card-header,
  .card-body,
  .hero {
    padding: 18px;
  }

  .card-title {
    font-size: 24px;
  }

  .card-subtitle {
    font-size: 15px;
    line-height: 1.45;
  }

  .hero-top {
    margin-bottom: 2px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stats-grid .stat-card:last-child {
    grid-column: 1 / -1;
  }

  .stat-card {
    padding: 14px;
    border-radius: 16px;
  }

  .stat-card:first-child,
  .stat-card:nth-child(2) {
    background: rgba(15, 23, 42, 0.60);
  }

  .stat-label {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .time-main {
    font-size: 40px;
  }

  .time-secondary {
    font-size: 24px;
  }

  .segment-name {
    font-size: 18px;
  }

  .segment-sub {
    font-size: 12px;
    line-height: 1.3;
  }

  .progress-meta {
    font-size: 12px;
  }

  .actions,
  .top-actions {
    flex-direction: column;
  }

    .settings-box {
    padding: 14px;
  }

  input[type="time"],
  input[type="number"] {
    font-size: 16px;
  }

    .editor-header {
    flex-direction: column;
    align-items: stretch;
  }

  .toggle-segment-btn {
    width: 100%;
  }
  
  .endtime-value {
    font-size: 16px;
  }

  button {
    width: 100%;
  }

    .segment-row {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    }

    .segment-row > div:first-child {
    flex: 1;
    min-width: 0;
    }

    .segment-row > div:last-child {
    flex: 0 0 auto;
    text-align: right;
    min-width: 68px;
    }

    .segment-duration {
    text-align: right;
    }
}