:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17201d;
  --muted: #66736f;
  --line: #ded8ca;
  --teal: #0f766e;
  --teal-dark: #0a4f4a;
  --coral: #c85242;
  --blue: #3861a8;
  --gold: #b68118;
  --shadow: 0 14px 34px rgba(27, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.11), transparent 220px),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -14px -16px 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: rgba(247, 244, 238, 0.88);
  border-bottom: 1px solid rgba(222, 216, 202, 0.72);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.18);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.06rem;
  line-height: 1.2;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 16px;
  min-height: 174px;
  overflow: hidden;
  padding: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(10, 79, 74, 0.95), rgba(15, 118, 110, 0.84)),
    url("./assets/court.svg") center / cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 6vw, 2.3rem);
}

.hero-panel p {
  margin-bottom: 0;
  line-height: 1.65;
}

.hero-panel .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.court-visual {
  position: relative;
  align-self: stretch;
  min-height: 130px;
  border: 2px solid rgba(255, 255, 255, 0.54);
  border-radius: 7px;
}

.court-visual::before,
.court-visual::after,
.court-visual span {
  position: absolute;
  content: "";
  background: rgba(255, 255, 255, 0.5);
}

.court-visual::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
}

.court-visual::after {
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
}

.court-visual span:first-child {
  top: 22%;
  left: 0;
  width: 100%;
  height: 1px;
}

.court-visual span:last-child {
  bottom: 22%;
  left: 0;
  width: 100%;
  height: 1px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.metric {
  min-height: 88px;
  padding: 14px 10px;
  text-align: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--teal-dark);
  font-size: 1.55rem;
  font-weight: 800;
}

.metric p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.section-block {
  margin-top: 18px;
}

.section-block.first {
  margin-top: 4px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entry-list,
.note-list,
.tag-bars,
.source-grid,
.event-list {
  display: grid;
  gap: 10px;
}

.entry-card,
.note-card,
.event-card,
.event-row {
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.entry-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.entry-card p,
.note-card p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.chip-row,
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.tag-option {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--teal-dark);
  font-size: 0.8rem;
  font-weight: 700;
  background: #e7f4ef;
  border: 1px solid #b9d9d1;
  border-radius: 999px;
}

.tag-option {
  color: var(--muted);
  background: var(--surface);
}

.tag-option.selected {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.tag-bar {
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tag-bar-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 700;
}

.bar-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: #ebe4d7;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: inherit;
}

.form-stack {
  display: grid;
  gap: 14px;
  padding-top: 4px;
}

label,
.field-label {
  display: grid;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--teal);
  background: transparent;
  border: none;
}

.range-value {
  color: var(--teal-dark);
  font-size: 0.82rem;
}

.form-row {
  display: grid;
  gap: 12px;
}

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

.advice-box {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  position: sticky;
  top: 72px;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 10px;
  margin: -4px -2px 14px;
  padding: 8px 2px;
  background: rgba(247, 244, 238, 0.9);
  backdrop-filter: blur(12px);
}

.search-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--teal-dark);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.text-button {
  min-height: 34px;
  padding: 0 4px;
  color: var(--teal-dark);
  background: transparent;
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  color: var(--teal-dark);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.danger-button {
  min-height: 34px;
  padding: 0 8px;
  color: #fff;
  background: var(--coral);
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.muted,
.plain-text {
  color: var(--muted);
  line-height: 1.6;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.48);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

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

.source-card {
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-card strong {
  display: block;
  color: var(--blue);
  font-size: 1.4rem;
}

.countdown-card {
  display: grid;
  gap: 10px;
}

.tournament-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  border-color: rgba(184, 129, 24, 0.42);
  background: linear-gradient(135deg, #fffdf8, #fff8e8);
}

.tournament-card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.tournament-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tournament-card strong {
  display: grid;
  place-items: center;
  min-width: 86px;
  min-height: 86px;
  padding: 8px;
  color: #fff;
  text-align: center;
  background: var(--gold);
  border-radius: 999px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.calendar-weekday,
.calendar-day {
  display: grid;
  place-items: center;
  min-height: 42px;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 8px;
}

.calendar-weekday {
  min-height: 26px;
  color: var(--muted);
}

.calendar-day {
  gap: 3px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.calendar-day.today {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.muted-day {
  background: transparent;
  border-color: transparent;
}

.calendar-dots {
  display: flex;
  min-height: 8px;
  gap: 3px;
}

.calendar-dots i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.practice-dot {
  background: var(--blue);
}

.tournament-dot {
  background: var(--coral);
}

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

.event-row strong {
  display: block;
  margin: 4px 0;
}

.event-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.event-kind {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
}

.event-kind.practice {
  background: var(--blue);
}

.event-kind.tournament {
  background: var(--coral);
}

.schedule-form-block {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.tab {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 58px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.tab span {
  font-size: 1.08rem;
  line-height: 1;
}

.tab.active {
  color: #fff;
  background: var(--teal);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 50;
  display: none;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 13px 14px;
  color: #fff;
  text-align: center;
  background: rgba(23, 32, 29, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

@media (max-width: 430px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    min-height: 220px;
  }

  .court-visual {
    min-height: 74px;
  }

  .form-row.two,
  .settings-actions,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 82px;
  }
}
