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

:root {
  --bg:        #fdf6ec;
  --surface:   #fff8f0;
  --accent:    #f4a5a5;
  --accent-2:  #a5c4f4;
  --text:      #4a4a4a;
  --subtle:    #9a9a9a;
  --success:   #a5f4b8;
  --border:    #e8ddd0;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0, 0, 0, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.user-info {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

[data-state="idle"] .user-info,
[data-state="running"] .user-info,
[data-state="expired"] .user-info,
[data-state="logging"] .user-info {
  display: flex;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.user-name {
  font-size: 0.8rem;
  color: var(--subtle);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--subtle);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Main layout ── */

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

section {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0.875rem;
  width: 100%;
  max-width: 360px;
}

[data-state="auth"]    .state-auth    { display: flex; }
[data-state="idle"]    .state-idle    { display: flex; }
[data-state="running"] .state-running { display: flex; }
[data-state="expired"] .state-expired { display: flex; }
[data-state="logging"] .state-logging { display: flex; }

/* ── Form controls ── */

input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  font-size: 1.1rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: var(--subtle);
}

/* ── Buttons ── */

.btn-primary,
.btn-secondary {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}

a.btn-primary,
a.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-primary:hover  { opacity: 0.9; }
.btn-secondary:hover { border-color: var(--subtle); }

.btn-primary:active,
.btn-secondary:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ── Auth state ── */

.state-auth {
  align-items: center;
  text-align: center;
  gap: 1.75rem;
}

.tagline {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--subtle);
  letter-spacing: -0.01em;
}

.state-auth .btn-primary {
  max-width: 240px;
}

/* ── Idle state ── */

.duration-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.duration-row input[type="number"] {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
}

.duration-row label {
  color: var(--subtle);
  font-size: 0.9rem;
  white-space: nowrap;
}


/* ── Running state ── */

.state-running {
  align-items: center;
  gap: 1.25rem;
}

.task-label {
  font-size: 0.9rem;
  color: var(--subtle);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clock {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(3.5rem, 20vw, 6rem);
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1;
}

/* ── Expired state ── */

.state-expired {
  align-items: center;
  gap: 1rem;
}

.overtime {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  color: var(--accent);
}

.log-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.log-panel label {
  font-size: 0.875rem;
  color: var(--subtle);
}

.hint {
  font-size: 0.8rem;
  color: var(--subtle);
  text-align: center;
  margin-top: -0.125rem;
}

/* ── Logging/confirm state ── */

.state-logging {
  align-items: center;
}

.confirm-msg {
  font-size: 1rem;
  text-align: center;
  color: var(--text);
  background: var(--success);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  width: 100%;
  line-height: 1.6;
}
