:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-text: #1f2430;
  --color-muted: #6b7280;
  --color-border: #e2e4e9;
  --color-primary: #2f6fed;
  --color-primary-dark: #1f4fb8;
  --color-danger: #d64545;
  --color-success: #1a9c6d;
  --color-holiday: #8b8fa3;
  --color-work-badge: #e7f0ff;
  --color-move-badge: #fff3e2;
  --color-break-badge: #eef0f3;
  --radius: 12px;
  --tap-min: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px 90px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 17px;
  margin: 0;
}

.app-header .user-name {
  font-size: 13px;
  color: var(--color-muted);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.flash-success { background: #e6f7ef; color: var(--color-success); border: 1px solid #b8e6cf; }
.flash-error { background: #fdecec; color: var(--color-danger); border: 1px solid #f3c1c1; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.month-nav .month-label {
  font-size: 18px;
  font-weight: 700;
}
.month-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  text-decoration: none;
  font-size: 20px;
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: var(--tap-min);
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}
.day-row .date-badge {
  width: 44px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}
.day-row .weekday {
  font-size: 11px;
  color: var(--color-muted);
  display: block;
  font-weight: 400;
}
.day-row .status-text {
  flex: 1;
  font-size: 14px;
}
.day-row .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-not_input .status-dot { background: var(--color-border); }
.status-not_input { color: var(--color-muted); }
.status-input_done .status-dot { background: var(--color-success); }
.status-holiday .status-dot { background: var(--color-holiday); }
.status-holiday { color: var(--color-holiday); }
.day-row.weekday-sun .date-badge { color: var(--color-danger); }
.day-row.weekday-sat .date-badge { color: var(--color-primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:active { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-danger { background: #fff; color: var(--color-danger); border: 1px solid #f3c1c1; }
.btn-block-row { display: flex; gap: 8px; }
.btn-block-row .btn { width: auto; flex: 1; }

label {
  display: block;
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}
label:first-child { margin-top: 0; }

input[type="text"], input[type="time"], input[type="date"], textarea, select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
}
textarea { min-height: 72px; resize: vertical; }

.day-type-toggle {
  display: flex;
  gap: 8px;
}
.day-type-toggle label {
  flex: 1;
  margin: 0;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}
.day-type-toggle input { display: none; }
.day-type-toggle input:checked + span { color: var(--color-primary); }
.day-type-toggle label:has(input:checked) { border-color: var(--color-primary); background: var(--color-work-badge); }

.time-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-range-row .sep { color: var(--color-muted); }

.segment-card {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}
.segment-card.type-work { border-left: 5px solid var(--color-primary); }
.segment-card.type-move { border-left: 5px solid #e0982a; }
.segment-card.type-break { border-left: 5px solid #8b8fa3; }

.segment-type-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-work { background: var(--color-work-badge); color: var(--color-primary-dark); }
.badge-move { background: var(--color-move-badge); color: #a85e10; }
.badge-break { background: var(--color-break-badge); color: var(--color-muted); }

.segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remove-segment-btn {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
}
.remove-segment-btn:active { color: var(--color-danger); }

.add-segment-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.add-segment-row button {
  font-size: 13px;
  padding: 10px 6px;
}

.sticky-save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--color-border);
  z-index: 20;
}
.sticky-save-bar .btn { max-width: 480px; margin: 0 auto; }

.helper-text { font-size: 12px; color: var(--color-muted); margin-top: 4px; }

.month-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.month-summary-table th, .month-summary-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 8px 4px;
  text-align: left;
}

.issue-list {
  background: #fff8e6;
  border: 1px solid #f3dfa3;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.issue-list ul { margin: 6px 0 0; padding-left: 18px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { text-align: center; font-size: 20px; margin-bottom: 20px; }
