:root {
  color-scheme: light;
  --page: #eef2f6;
  --phone: #f7f9fb;
  --surface: #ffffff;
  --soft: #edf1f4;
  --text: #17212b;
  --sub: #66727f;
  --line: #dbe1e6;
  --green: #20b986;
  --green-ink: #063d2d;
  --red: #d84455;
  --pink: #ed5f9b;
  --blue: #2d9aff;
  --yellow: #b77a00;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--page);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--phone);
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-header {
  min-height: 74px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 11px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  background: color-mix(in srgb, var(--phone) 94%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.app-header h1 { font-size: 21px; font-weight: 600; line-height: 1.15; margin: 0; }
.header-title { min-width: 0; }
.header-title p { margin: 3px 0 0; color: var(--sub); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.app-main { flex: 1; padding: 0 14px calc(82px + var(--safe-bottom)); display: grid; align-content: start; gap: 10px; }
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 430px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  padding: 7px 4px calc(9px + var(--safe-bottom));
  z-index: 20;
  backdrop-filter: blur(14px);
}
.bottom-nav button { border: 0; background: transparent; color: var(--sub); display: grid; gap: 2px; justify-items: center; padding: 3px; font-size: 11px; }
.bottom-nav button span:first-child { font-size: 13px; }
.bottom-nav button.is-current { color: var(--green); font-weight: 600; }

.icon-button, .text-button {
  border: 0;
  background: transparent;
  color: var(--text);
  min-height: 40px;
  padding: 7px 8px;
  border-radius: 10px;
}
.icon-button:active, .text-button:active { background: var(--soft); }
.primary-button, .secondary-button, .danger-button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 13px;
  color: var(--text);
  background: var(--soft);
}
.primary-button { background: var(--green); border-color: var(--green); color: var(--green-ink); font-weight: 600; }
.danger-button { background: color-mix(in srgb, var(--red) 10%, var(--surface)); border-color: color-mix(in srgb, var(--red) 38%, var(--line)); color: var(--red); }
.block-button { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button-row.three { grid-template-columns: 1fr 1.35fr 1fr; }

.panel, .list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.panel { padding: 13px; }
.panel.warning { background: color-mix(in srgb, #ffcc4d 14%, var(--surface)); border-color: #e0ad2f; }
.panel.timer { background: color-mix(in srgb, var(--green) 11%, var(--surface)); border-color: var(--green); }
.panel h2, .panel h3 { margin: 0; font-size: 15px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row.start { align-items: flex-start; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.sub { color: var(--sub); font-size: 12px; }
.note { color: var(--sub); font-size: 11px; margin: 5px 0 0; }
.section-heading { margin: 5px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading h2 { margin: 0; font-size: 15px; }

.progress-value { font-size: 28px; font-weight: 600; }
.progress-track { margin-top: 9px; height: 9px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); border-radius: inherit; }
.progress-bar.over { background: var(--red); }
.zone { color: var(--red); font-weight: 600; }
.timer-value { font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; }

.field-group { display: grid; gap: 6px; min-width: 0; }
.field-group label, .field-label { color: var(--sub); font-size: 12px; }
.field, select.field, textarea.field {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--phone);
  color: var(--text);
  padding: 11px;
  min-height: 44px;
}
textarea.field { min-height: 82px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-grid > * { min-width: 0; }
.color-field { height: 44px; padding: 4px; }
.duration-field { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 5px; }
.duration-field input { text-align: center; }

.heart-control { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.heart-control button { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--text); font-size: 18px; }
.heart-control .attend { background: var(--green); border-color: var(--green); color: var(--green-ink); font-size: 15px; font-weight: 600; }
.heart-number { text-align: center; font-size: 22px; font-weight: 600; }

.list { overflow: hidden; }
.list-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}
.list-row:last-child { border-bottom: 0; }
.list-row:active { background: var(--soft); }
.list-copy { min-width: 0; flex: 1; }
.name { font-weight: 600; }
.check { color: var(--green); }
.favorite { color: var(--yellow); }
.memo-preview { margin: 5px 0 0; font-size: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-state { text-align: center; padding: 26px 16px; color: var(--sub); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 5px; }

.member-badge { display: inline-flex; width: 45px; height: 18px; align-items: center; justify-content: center; padding: 0; border-radius: 99px; background: linear-gradient(100deg, var(--red), var(--pink), var(--blue)); color: white; font-size: 10px; line-height: 1; font-weight: 600; vertical-align: middle; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; border: 1px solid var(--line); border-radius: 99px; padding: 5px 9px; background: var(--surface); color: var(--sub); font-size: 12px; }
button.chip { color: var(--text); }
.chip.is-on { border-color: var(--green); color: var(--text); }
.toolbar { display: flex; gap: 7px; flex-wrap: wrap; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.hidden-filter { border-color: color-mix(in srgb, var(--red) 42%, var(--line)); color: var(--red); }
.privacy-panel { background: color-mix(in srgb, var(--green) 10%, var(--surface)); border-color: var(--green); }
.mini-actions { display: grid; grid-template-columns: 38px 38px auto; align-items: center; gap: 1px; flex: 0 0 auto; }
.mini-actions button:disabled { opacity: .28; }

.streamer-card { display: grid; gap: 8px; }
.streamer-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.k-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.k-tile { background: var(--soft); border-radius: 9px; text-align: center; padding: 7px 2px; font-size: 11px; }
.k-tile strong { display: block; color: var(--green); margin-top: 2px; font-size: 13px; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.weekday { text-align: center; color: var(--sub); font-size: 11px; padding: 4px 0; }
.day {
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.day.empty { background: transparent; }
.day.selected { outline: 2px solid var(--green); background: color-mix(in srgb, var(--green) 11%, var(--surface)); }
.day-number { text-align: center; font-size: 12px; }
.day-data { text-align: center; font-size: 9px; color: var(--sub); line-height: 1.15; white-space: nowrap; overflow: hidden; }
.day-event { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 4px; padding: 1px 2px; font-size: 9px; line-height: 1.2; text-align: left; }
.more-events { font-size: 9px; text-align: center; color: var(--sub); }
.event-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.event-date { flex: 0 0 64px; color: var(--sub); font-size: 11px; font-variant-numeric: tabular-nums; }
.event-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 11px; background: var(--soft); }
.segment button { border: 0; border-radius: 8px; padding: 8px 4px; background: transparent; color: var(--text); }
.segment button.is-current { background: var(--surface); box-shadow: 0 1px 4px rgba(20,35,48,.1); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.metric { background: var(--soft); border-radius: 11px; padding: 9px; min-width: 0; }
.metric strong { display: block; margin-top: 3px; font-size: 15px; }
.route { border-left: 4px solid var(--green); padding-left: 10px; }
.song-badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 5px 10px; color: white; font-size: 12px; font-weight: 600; }

.app-dialog { width: min(calc(100% - 24px), 410px); max-height: calc(100dvh - 24px); border: 0; border-radius: 22px; padding: 0; color: var(--text); background: var(--phone); box-shadow: 0 20px 50px rgba(20,35,48,.25); }
.app-dialog::backdrop { background: rgba(17, 24, 31, .42); backdrop-filter: blur(2px); }
.dialog-header { position: sticky; top: 0; z-index: 1; background: var(--phone); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 9px; }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.dialog-footer { position: sticky; bottom: 0; background: var(--phone); padding: 9px 14px calc(14px + var(--safe-bottom)); display: grid; grid-template-columns: 1fr 1.7fr; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-bottom)); transform: translate(-50%, 16px); background: var(--text); color: var(--surface); padding: 9px 13px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; white-space: nowrap; max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 431px) {
  .app-shell { box-shadow: 0 0 0 1px var(--line), 0 18px 50px rgba(20,35,48,.12); }
}

@media (max-width: 350px) {
  .app-main { padding-inline: 10px; }
  .app-header { padding-inline: 12px; }
  .field-grid { gap: 6px; }
  .calendar { gap: 2px; }
  .day { min-height: 55px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
