:root {
  --bg: #FFFBF3;
  --surface: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #F3E8D7;
  --primary: #FFB300;
  --accent: #F59E0B;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 10px;
  --shadow: 0 8px 20px #0002;
  --page-padding-block: clamp(1rem, 2vw + 1rem, 3rem);
  --page-padding-inline: clamp(1rem, 2vw + 1rem, 3rem);
  --scrollbar-compensation: 0px;
}

html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  margin: 0;
  padding-block: var(--page-padding-block);
  padding-inline-start: var(--page-padding-inline);
  padding-inline-end: calc(var(--page-padding-inline) + var(--scrollbar-compensation));
  background: var(--bg);
  color: var(--text);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body::-webkit-scrollbar {
  display: none;
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
}

h1 {
  color: var(--text);
  font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem);
}

/* Header: center title, menu on the left */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 0.5rem;
}
.app-header h1 { grid-column: 2; text-align: center; margin: 0; }
.app-header .hamburger { grid-column: 1; justify-self: start; }

/* Optional left-aligned variant: add class .left to header */
.app-header.left { grid-template-columns: auto 1fr auto; }
.app-header.left h1 { grid-column: 1; text-align: left; }
.app-header.left .hamburger { grid-column: 3; }

ul {
  list-style: none;
  padding: 0.1rem;
  margin: 0;
}

li {
  margin-bottom: 0.5rem;
  font-size: clamp(1.1rem, 1vw + 1rem, 1.4rem);
}

.due-today {
  text-decoration: underline var(--accent);
  text-underline-offset: 4px;
}

.due-time {
  font-size: 1rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

.muted-text {
  color: var(--muted);
  font-size: 0.95rem;
}

.completed {
  /* text-decoration: line-through; */
  color: var(--muted);
  opacity: 0.7;
}

.top-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
}
.top-buttons .last-updated {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
.top-buttons .refresh-status {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
.refresh-status-success {
  color: var(--success);
}
.refresh-status-error {
  color: var(--danger);
}
.refresh-status {
  transition: color 0.2s ease, opacity 0.2s ease;
}
.refresh-status:not(.is-visible) {
  opacity: 0;
}

.status-banner {
  display: none;
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  background: #E2E8F0;
  color: #1E293B;
  font-size: 0.95rem;
  line-height: 1.35;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.status-banner.is-visible {
  display: block;
}

.status-banner.offline {
  background: #FEF3C7;
  color: #92400E;
  box-shadow: inset 0 0 0 1px rgba(194, 65, 12, 0.22);
}

.status-banner.sync {
  background: #DBEAFE;
  color: #1D4ED8;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.presence-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #E0E7FF;
  color: #3730A3;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-weight: 500;
}
.presence-label {
  font-weight: 600;
  color: #4B5563;
}

.data-transfer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-transfer-actions .btn {
  flex: 1 1 180px;
}

.data-transfer-status {
  min-height: 1.2rem;
}

.data-transfer-status.is-error {
  color: #b91c1c;
}

.data-transfer-status.is-success {
  color: #047857;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-item {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 0.75rem;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.session-item.current {
  border-color: #2563EB;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.session-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.session-item-meta {
  font-size: 0.85rem;
  color: #64748B;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.session-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.session-item-actions .btn {
  flex: 0 0 auto;
}

.editing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
  padding: 0.2rem 0.45rem;
  background: rgba(251, 191, 36, 0.2);
  color: #92400E;
  border-radius: 6px;
  font-size: 0.85rem;
}

li.is-editing {
  position: relative;
  border-left: 3px solid #F59E0B;
  padding-left: 0.75rem;
}

.top-buttons button {
  cursor: pointer;
}

.filter-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
}

.filter-bar .filter-search {
  flex: 1 1 240px;
  min-width: 180px;
}

.filter-date-range {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-date-range label {
  font-size: 0.95rem;
  color: var(--muted);
}

.filter-date-input {
  width: 11rem;
  min-width: 9rem;
}

.filter-date-separator {
  color: var(--muted);
}

.status-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.status-filter > span {
  font-size: 0.95rem;
  color: var(--muted);
}
.status-filter .status-filter-btn {
  font-size: 0.95rem;
  padding: 0.35rem 0.7rem;
}

/* Buttons */
.btn {
  font-size: 1rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn:hover { filter: brightness(0.98); }
.btn:active { filter: brightness(0.95); }
.btn-primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

/* Toggle button (more visible) */
.btn-toggle {
  background: #FFF3C4; /* soft amber */
  border-color: var(--accent);
  color: #7C5100;
}
.btn-toggle:hover { filter: brightness(0.98); }
.btn-toggle.is-on {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

/* Dashboard */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  box-shadow: var(--shadow);
}
.card.stat-card {
  min-width: 160px;
}
.stat-title { font-weight: 600; color: var(--muted); font-size: .95rem; margin-bottom: .2rem; }
.stat-body { font-size: 1.25rem; }
.stat-foot { color: var(--muted); font-size: .95rem; }
.dashboard-toolbar,
.dashboard-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}
.dashboard-row {
  align-items: stretch;
}
.dashboard-table-card {
  width: 100%;
  overflow: auto;
}
.dashboard-table-card table {
  width: 100%;
  border-collapse: collapse;
}

/* Inputs */
.input, .select {
  font-size: 1rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

/* Tag */
.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #FFF3C4; /* soft amber */
  color: #7C5100;
  font-size: 0.9rem;
}
.tag.project { background:#F1F5F9; color:#334155; }
.tag.project .dot {
  display:inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 999px;
  margin-right: 0.35em;
  vertical-align: -.1em;
}
.tag.repeat {
  background: #E0F2FE;
  color: #0C4A6E;
}

.recurrence-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.recurrence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.recurrence-row label {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.recurrence-weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.recurrence-weekdays label {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}
.recurrence-monthly-mode {
  display: flex;
  gap: 1rem;
}
.recurrence-monthly-option {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.recurrence-end {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.recurrence-end input[type="number"],
.recurrence-end input[type="date"] {
  max-width: 120px;
}
.recurrence-hint {
  font-size: 0.85rem;
}
.series-scope-options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.series-scope-options label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 1.5rem;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-overlay::-webkit-scrollbar { display: none; }

.modal-box {
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  text-align: left;
  box-shadow: var(--shadow);
  width: min(520px, 92vw);
  min-width: 260px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-box::-webkit-scrollbar { display: none; }

.modal-box button {
  margin: 0;
  font-size: 1rem;
  padding: 0.5rem 1rem;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}
.filter-modal-box {
  max-width: min(520px, 92vw);
}
.filter-modal-section {
  margin: 0.75rem 0;
}
.filter-modal-section label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.filter-modal-label {
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.category-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.category-filter-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}
.modal-actions .btn {
  flex: 0 1 auto;
  margin: 0;
}
.modal-box .input,
.modal-box .select,
.modal-box textarea {
  width: 100%;
  box-sizing: border-box;
}

.modal-box--wide {
  width: min(640px, 96vw);
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-stack--spacious {
  gap: 1rem;
}
.modal-stack--compact {
  gap: 0.5rem;
}
.modal-actions--wrap {
  gap: 0.5rem;
  flex-wrap: wrap;
}
.modal-flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.modal-heading {
  margin: 0.2rem 0;
}
.notify-channel {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
}
.notify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.notify-row--dense {
  gap: 0.5rem;
}
.notify-field {
  flex: 1 1 150px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.notify-field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.notify-input-compact {
  width: 5rem;
}
.notify-input-lead {
  width: 8rem;
}
.notify-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}
.history-label {
  font-size: 1.2rem;
  margin: 0 0 0.3rem;
}
.list-reset {
  list-style: none;
  padding: 0;
  margin: 0;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.modal-field-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.modal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.modal-grid .modal-field {
  flex: 1 1 200px;
}

.modal-subheading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-description {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.modal-box hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
  width: 100%;
}

.modal-footer-note {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Utility: layout and spacing */
.w-100 { width: 100%; }
.mt-05 { margin-top: .5rem; }
.ml-1 { margin-left: 1rem; }
.fs-110 { font-size: 1.1rem; }
.flex-between-center { display:flex; justify-content:space-between; align-items:center; }
.text-center { text-align: center; }
.mt-025 { margin-top: 0.25rem; }
.mb-025 { margin-bottom: 0.25rem; }
.mt-075 { margin-top: 0.75rem; }
.mb-05 { margin-bottom: 0.5rem; }
.mb-075 { margin-bottom: 0.75rem; }
.align-end { align-items: flex-end; }
.flex-grow { flex: 1 1 0; min-width: 0; }
.flex-1-220 { flex: 1 1 220px; min-width: 0; }
.gap-05 { gap: 0.5rem; }
.hidden { display: none !important; }
.table-header,
.table-cell {
  padding: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.table-header--left { text-align: left; }
.table-header--right { text-align: right; }
.table-cell--left { text-align: left; }
.table-cell--right { text-align: right; }

/* Auth page */
.auth-box {
  max-width: 420px;
  margin: 4rem auto;
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.tabs { display:flex; gap:1rem; justify-content:center; margin-bottom:1rem; }
.tabs button { padding: .5rem 1rem; cursor: pointer; }
form.auth { display:flex; flex-direction: column; gap: .75rem; }
.error { color: var(--danger); min-height: 1.2rem; text-align: center; }

/* Hamburger menu */
.hamburger {
  font-size: 1.6rem;
  padding: .2rem .6rem;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  z-index: 1000;
}
.side-menu {
  width: 300px;
  max-width: 85vw;
  height: 100vh;
  background: var(--surface);
  padding: 1rem;
  box-shadow: 2px 0 14px #0004;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.menu-overlay.is-open .side-menu {
  transform: translateX(0);
}
.side-menu h3 {
  margin: 0;
}

@media (max-width: 640px) {
  .app-header {
    grid-template-columns: auto 1fr;
    column-gap: 0.5rem;
  }

  .app-header h1 {
    text-align: left;
  }

  .top-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .top-buttons .btn {
    width: 100%;
  }

  .ml-1 {
    margin-left: 0;
  }

  .modal-box {
    width: 94vw;
    min-width: auto;
    padding: 1rem;
    max-height: calc(100vh - 2rem);
  }

  .modal-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .modal-actions .btn {
    flex: 1 1 100%;
    min-width: auto;
  }

}
