* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #FFF8EC;
  color: #3B2E20;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── オフラインバナー ── */
.offline-banner {
  display: none;
  background: #78350f;
  color: #fed7aa;
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
}
.offline-banner.show { display: block; }

.registration-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: #FFF8EC;
  padding: clamp(16px, 4vw, 40px);
}
.registration-view.show { display: flex; }
.registration-box {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: #fff;
  border: 2px solid #3B2E20;
  border-radius: 24px;
  padding: 34px;
  box-shadow: 6px 6px 0 rgba(59,46,32,.18);
}
.registration-brand-logo {
  display: block;
  width: 180px;
  height: auto;
  margin: 0 auto 20px;
}
.registration-box h1 {
  font-size: 28px;
  line-height: 1.3;
  margin-bottom: 12px;
}
.registration-box p {
  font-size: 14px;
  color: #8F8372;
  line-height: 1.7;
  margin-bottom: 20px;
}
.registration-box label {
  display: block;
  font-size: 12px;
  color: #8F8372;
  font-weight: 700;
  margin-bottom: 6px;
}
.registration-box input {
  width: 100%;
  border: 2px solid #3B2E20;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 22px;
  font-family: inherit;
  margin-bottom: 14px;
}
.registration-box button {
  width: 100%;
  border: none;
  border-radius: 16px;
  background: #D97757;
  color: #fff;
  padding: 16px;
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
}
.registration-message {
  min-height: 18px;
  margin-top: 12px;
  color: #DC2626;
  font-size: 13px;
}

/* ── アプリ本体 ── */
.tablet-app {
  flex: 1;
  width: 100%;
  display: flex;
  min-height: 0;
  min-width: 0;
  position: relative;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(245,158,11,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(99,102,241,0.06) 0%, transparent 50%);
}

/* ── 左サイドバー ── */
.tablet-sidebar {
  width: clamp(232px, 25vw, 320px);
  padding: clamp(16px, 2.2vw, 28px) clamp(14px, 1.9vw, 24px);
  border-right: 1px solid #EFE4CF;
  background: linear-gradient(180deg, #FFFCF5 0%, #FFF8EC 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.tablet-brand-logo {
  display: block;
  width: 150px;
  height: auto;
  margin-bottom: 18px;
}

.tablet-sidebar .facility-name {
  font-size: 14px;
  color: #8F8372;
  font-weight: 700;
  letter-spacing: 2px;
}

.tablet-sidebar .greeting {
  font-size: clamp(24px, 2.5vw, 32px);
  font-weight: 800;
  margin-top: 24px;
  line-height: 1.3;
}

.tablet-sidebar .today-date {
  font-size: 15px;
  color: #8F8372;
  margin-top: 8px;
}

.clock-panel { text-align: center; padding: 20px 0; }

.clock-hour-minute {
  font-size: clamp(56px, 7vw, 88px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: 4px;
  color: #3B2E20;
  line-height: 1;
}

.clock-second {
  font-size: 18px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: #8F8372;
  margin-top: 6px;
  letter-spacing: 2px;
}

.status-panel {
  background: #fff;
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid #EFE4CF;
}

.status-panel .panel-label {
  font-size: 12px;
  color: #8F8372;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.status-row:last-child { margin-bottom: 0; }

.status-dot-sm {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-color-none { color: #DC2626; }
.status-color-in { color: #15803D; }
.status-color-done { color: #78716C; }
.status-dot-sm.status-color-none { background: #DC2626; }
.status-dot-sm.status-color-in { background: #15803D; }
.status-dot-sm.status-color-done { background: #78716C; }

.status-row-label {
  flex: 1;
  font-size: 14px;
}

.status-count {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ── 右メインエリア ── */
.tablet-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ── view 共通 ── */
.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* ── STEP1: 五十音行選択 ── */
.row-view {
  padding: clamp(18px, 3.2vw, 40px) clamp(18px, 3.8vw, 48px) clamp(14px, 2.5vw, 32px);
}

.row-step-label {
  font-size: 14px;
  color: #8F8372;
  font-weight: 700;
  letter-spacing: 2px;
}

.row-title {
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 800;
  margin-top: 6px;
  line-height: 1.2;
}

.row-sub {
  font-size: 15px;
  color: #8F8372;
  margin-top: 8px;
}

.row-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(7px, 1.1vw, 14px);
  margin-top: clamp(12px, 2.5vh, 32px);
}

.row-card {
  background: var(--row-bg);
  border-color: var(--row-border);
  box-shadow: var(--row-shadow);
  border-radius: clamp(14px, 1.9vw, 24px);
  padding: clamp(8px, 1.4vw, 18px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: all 0.12s;
  font-family: inherit;
  color: #3B2E20;
  border: 2px solid var(--row-border);
}
.row-card:disabled {
  background: #F5EFE3;
  border-color: #EFE4CF;
  box-shadow: none;
  cursor: default;
  opacity: 0.45;
}
.row-card:not(:disabled):active {
  transform: translateY(2px);
}
.row-theme-0 { --row-bg: #FFE5E5; --row-accent: #F87171; --row-border: #F8717155; --row-shadow: 0 3px 0 #F8717133, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #F8717122; }
.row-theme-1 { --row-bg: #FFEFD5; --row-accent: #FB923C; --row-border: #FB923C55; --row-shadow: 0 3px 0 #FB923C33, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #FB923C22; }
.row-theme-2 { --row-bg: #FEF3C7; --row-accent: #F59E0B; --row-border: #F59E0B55; --row-shadow: 0 3px 0 #F59E0B33, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #F59E0B22; }
.row-theme-3 { --row-bg: #DCFCE7; --row-accent: #34D399; --row-border: #34D39955; --row-shadow: 0 3px 0 #34D39933, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #34D39922; }
.row-theme-4 { --row-bg: #D1FAE5; --row-accent: #10B981; --row-border: #10B98155; --row-shadow: 0 3px 0 #10B98133, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #10B98122; }
.row-theme-5 { --row-bg: #DBEAFE; --row-accent: #60A5FA; --row-border: #60A5FA55; --row-shadow: 0 3px 0 #60A5FA33, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #60A5FA22; }
.row-theme-6 { --row-bg: #E0E7FF; --row-accent: #818CF8; --row-border: #818CF855; --row-shadow: 0 3px 0 #818CF833, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #818CF822; }
.row-theme-7 { --row-bg: #F3E8FF; --row-accent: #A78BFA; --row-border: #A78BFA55; --row-shadow: 0 3px 0 #A78BFA33, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #A78BFA22; }
.row-theme-8 { --row-bg: #FCE7F3; --row-accent: #F472B6; --row-border: #F472B655; --row-shadow: 0 3px 0 #F472B633, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #F472B622; }
.row-theme-9 { --row-bg: #FFE4E6; --row-accent: #FB7185; --row-border: #FB718555; --row-shadow: 0 3px 0 #FB718533, 0 1px 2px rgba(0,0,0,0.04); --row-deco: #FB718522; }
.row-card-deco {
  position: absolute;
  top: -22px;
  right: -22px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--row-deco);
  pointer-events: none;
}
.row-card-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  position: relative;
}

.row-card-key {
  font-size: clamp(34px, 5vw, 64px);
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--row-accent);
}
.row-card:disabled .row-card-key { color: #8F8372; }

.row-card-emoji {
  font-size: 24px;
}

.row-card-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  position: relative;
}

.row-card-count {
  font-size: 13px;
  color: #8F8372;
}

.row-card-count b {
  color: #3B2E20;
  font-size: 18px;
}

.row-card-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.row-card-disabled-label {
  font-size: 12px;
  color: #8F8372;
  margin-top: 8px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid transparent;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.stat-chip--none { color: #DC2626; border-color: #DC262633; }
.stat-chip--in { color: #15803D; border-color: #15803D33; }
.stat-chip--done { color: #A8A29E; border-color: #A8A29E33; }
.stat-chip--none .stat-chip-dot { background: #DC2626; }
.stat-chip--in .stat-chip-dot { background: #15803D; }
.stat-chip--done .stat-chip-dot { background: #A8A29E; }

/* 凡例 */
.row-legend {
  margin-top: clamp(8px, 1.6vh, 20px);
  padding: clamp(7px, 1vh, 12px) 18px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #EFE4CF;
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #8F8372;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-dot--none { background: #DC2626; }
.legend-dot--in { background: #15803D; }
.legend-dot--done { background: #A8A29E; }

@media (max-height: 720px) and (min-width: 701px) {
  .tablet-sidebar { padding: 12px 16px; }
  .tablet-brand-logo { width: 120px; margin-bottom: 8px; }
  .tablet-sidebar .greeting { font-size: 22px; margin-top: 8px; }
  .tablet-sidebar .today-date { font-size: 13px; margin-top: 4px; }
  .clock-panel { padding: 8px 0; }
  .clock-hour-minute { font-size: 54px; }
  .clock-second { font-size: 14px; margin-top: 2px; }
  .status-panel { padding: 10px 12px; }
  .status-panel .panel-label { margin-bottom: 5px; }
  .status-row { margin-bottom: 4px; }
  .row-view { padding: 14px 24px 10px; }
  .row-title { font-size: 27px; }
  .row-sub { margin-top: 4px; }
  .row-grid { margin-top: 10px; gap: 7px; }
  .row-card { padding: 8px; border-radius: 14px; }
  .row-card-key { font-size: 38px; }
  .row-card-emoji { font-size: 18px; }
  .row-card-bottom { gap: 3px; margin-top: 3px; }
  .row-card-count { font-size: 11px; }
  .row-card-count b { font-size: 14px; }
  .stat-chip { padding: 1px 5px; font-size: 10px; }
  .row-legend { margin-top: 7px; padding: 5px 12px; }
}

@media (max-width: 700px), (max-width: 900px) and (orientation: portrait) {
  .tablet-app { flex-direction: column; }
  .tablet-sidebar {
    width: 100%;
    height: clamp(96px, 18vh, 136px);
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid #EFE4CF;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  .tablet-sidebar > div:first-child { flex: 1; min-width: 0; }
  .tablet-brand-logo { width: 104px; margin-bottom: 3px; }
  .tablet-sidebar .facility-name,
  .tablet-sidebar .today-date {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tablet-sidebar .facility-name { font-size: 11px; letter-spacing: 1px; }
  .tablet-sidebar .greeting { font-size: 17px; margin-top: 3px; }
  .tablet-sidebar .today-date { font-size: 11px; margin-top: 2px; }
  .clock-panel { width: 108px; padding: 0; flex-shrink: 0; }
  .clock-hour-minute { font-size: 40px; letter-spacing: 1px; }
  .clock-second { font-size: 12px; margin-top: 2px; letter-spacing: 1px; }
  .status-panel { width: 174px; padding: 8px 10px; flex-shrink: 0; }
  .status-panel .panel-label { display: none; }
  .status-row { gap: 6px; margin-bottom: 3px; }
  .status-row-label { font-size: 11px; }
  .status-count { font-size: 14px; }
  .row-view { padding: 12px; }
  .row-step-label { font-size: 11px; }
  .row-title { font-size: clamp(19px, 5vw, 25px); margin-top: 3px; }
  .row-sub { font-size: 12px; margin-top: 3px; }
  .row-grid { margin-top: 10px; gap: 6px; }
  .row-card { padding: 7px; border-radius: 12px; }
  .row-card-key { font-size: clamp(28px, 9vw, 42px); }
  .row-card-emoji { display: none; }
  .row-card-bottom { gap: 2px; margin-top: 2px; }
  .row-card-count { font-size: 10px; }
  .row-card-count b { font-size: 13px; }
  .row-card-dots { gap: 2px; }
  .stat-chip { padding: 1px 4px; font-size: 9px; }
  .stat-chip-dot { width: 4px; height: 4px; }
  .row-card-disabled-label { font-size: 9px; margin-top: 3px; }
  .row-legend { margin-top: 7px; padding: 5px 8px; gap: 12px; font-size: 10px; }
}

@media (max-width: 480px) {
  .tablet-sidebar { height: 88px; }
  .tablet-brand-logo { width: 96px; }
  .tablet-sidebar .greeting,
  .tablet-sidebar .today-date,
  .status-panel { display: none; }
  .clock-panel { width: 104px; }
  .row-title { font-size: 18px; }
  .row-sub { display: none; }
  .row-grid { margin-top: 7px; }
  .row-card { padding: 5px; }
  .row-card-key { font-size: clamp(25px, 8vw, 34px); }
  .row-card-count { display: none; }
  .row-legend { gap: 8px; }
}

