/* ==========================================================================
   Reversi Lab — Kumo Developer Control Panel UI
   Built upon official @cloudflare/kumo 2.14.0 semantic tokens & design specs
   ========================================================================== */

:root {
  /* Official Kumo Typography Stack */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Kumo Semantic Surfaces & Colors */
  --color-kumo-canvas: #f9fafb;
  --color-kumo-base: #ffffff;
  --color-kumo-elevated: #f3f4f6;
  --color-kumo-recessed: #e5e7eb;
  --color-kumo-tint: #f3f4f6;
  --color-kumo-contrast: #111827;
  --color-kumo-line: rgba(0, 0, 0, 0.1);
  --color-kumo-hairline: rgba(0, 0, 0, 0.06);
  --color-kumo-fill: #e5e7eb;
  --color-kumo-fill-hover: #f3f4f6;
  --color-kumo-focus: #111827;

  /* Official Kumo Brand Token */
  --color-kumo-brand: oklch(57.72% 0.2324 260);
  --color-kumo-brand-hover: #1d4ed8;

  /* Kumo Text Hierarchy */
  --text-color-kumo-default: #1f2937;
  --text-color-kumo-strong: #111827;
  --text-color-kumo-subtle: #6b7280;
  --text-color-kumo-inverse: #ffffff;
  --text-color-kumo-placeholder: #9ca3af;

  /* Semantic Status Palette */
  --color-kumo-success: #059669;
  --color-kumo-success-tint: #ecfdf5;
  --color-kumo-warning: #d97706;
  --color-kumo-warning-tint: #fffbeb;
  --color-kumo-danger: #dc2626;
  --color-kumo-danger-tint: #fef2f2;
  --color-kumo-info: #2563eb;
  --color-kumo-info-tint: #eff6ff;

  /* Concentric Radii */
  --radius-outer: 8px;
  --radius-inner: 6px;
  --radius-sm: 4px;
  --radius-xs: 2px;

  /* Kumo Thin Ring & Shadow System */
  --shadow-kumo-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-kumo-card: 0 0 0 1px var(--color-kumo-line), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-kumo-elevated: 0 0 0 1px var(--color-kumo-line), 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);

  /* Legacy variable mappings for backward compatibility */
  --bg-main: var(--color-kumo-canvas);
  --bg-card: var(--color-kumo-base);
  --bg-subtle: var(--color-kumo-elevated);
  --bg-sidebar: var(--color-kumo-base);
  --bg-topbar: var(--color-kumo-base);
  --border: var(--color-kumo-line);
  --border-strong: var(--color-kumo-contrast);
  --border-subtle: var(--color-kumo-hairline);
  --border-focus: var(--color-kumo-brand);
  --text-main: var(--text-color-kumo-strong);
  --text-muted: var(--text-color-kumo-subtle);
  --text-dim: #9ca3af;
  --primary: var(--color-kumo-contrast);
  --primary-hover: #1f2937;
  --primary-active: #000000;
  --primary-subtle: var(--color-kumo-info-tint);
  --primary-border: rgba(37, 99, 235, 0.2);
  --success: var(--color-kumo-success);
  --success-subtle: var(--color-kumo-success-tint);
  --success-border: rgba(5, 150, 105, 0.2);
  --warning: var(--color-kumo-warning);
  --warning-subtle: var(--color-kumo-warning-tint);
  --warning-border: rgba(217, 119, 6, 0.2);
  --danger: var(--color-kumo-danger);
  --danger-subtle: var(--color-kumo-danger-tint);
  --danger-border: rgba(220, 38, 38, 0.2);

  /* Reversi Board Precision Palette (preserved exactly) */
  --board-bg: #1c7340;
  --board-cell: #227b47;
  --board-cell-hover: #27874e;
  --board-grid: #165e32;
  --board-frame: #1c1c1e;
  --disc-black: #18181b;
  --disc-white: #fdfdfd;

  --radius-lg: 8px;
  --radius: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-kumo-canvas);
  color: var(--text-color-kumo-default);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Accessibility utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Compact Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}

/* Inline Monospace Text */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--color-kumo-elevated);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: var(--text-color-kumo-strong);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* ==========================================================================
   Shell Layout (Sidebar, Topbar, Main Canvas)
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Kumo Sidebar: 224px, resource grouped, square-ish active rows */
.app-sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--color-kumo-base);
  border-right: 1px solid var(--color-kumo-line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  user-select: none;
}

.sidebar-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-kumo-line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-color-kumo-strong);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: normal;
}

/* Clean Reversi Disc Brand Glyph */
.brand-logo-disc {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-kumo-contrast);
  position: relative;
  flex-shrink: 0;
  display: inline-block;
}

.brand-logo-disc::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #ffffff;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  color: var(--text-color-kumo-subtle);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-inner);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
  flex-shrink: 0;
  color: var(--text-color-kumo-subtle);
  vertical-align: middle;
}

.nav-item:hover {
  color: var(--text-color-kumo-strong);
  background-color: var(--color-kumo-fill-hover);
}

.nav-item:hover svg {
  color: var(--text-color-kumo-strong);
}

.nav-item.active {
  color: var(--text-color-kumo-strong);
  background-color: var(--color-kumo-recessed);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--text-color-kumo-strong);
  stroke-width: 2;
}

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--color-kumo-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  background: var(--color-kumo-elevated);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  border-radius: var(--radius-sm);
  color: var(--text-color-kumo-subtle);
}

.sidebar-chip::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-kumo-brand);
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 990;
}

/* Main Area Wrapper */
.app-main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Kumo Compact Topbar: 48px, crisp separated border, breadcrumbs & actiongroup */
.app-topbar {
  height: 48px;
  background: var(--color-kumo-base);
  border-bottom: 1px solid var(--color-kumo-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  background: var(--color-kumo-base);
  border: none;
  border-radius: var(--radius-inner);
  color: var(--text-color-kumo-strong);
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--color-kumo-fill-hover);
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color-kumo-strong);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 520px;
}

.topbar-crumb-link {
  color: var(--text-color-kumo-subtle);
  text-decoration: none;
}

.topbar-crumb-link:hover {
  color: var(--text-color-kumo-strong);
}

.topbar-crumb-sep {
  color: var(--text-color-kumo-placeholder);
  font-size: 12px;
}

.topbar-crumb-id {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-color-kumo-strong);
  background: var(--color-kumo-elevated);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* User Role Indicator */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.role-badge::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.role-operator {
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}
.role-operator::before {
  background: #2563eb;
}

.role-viewer {
  background: var(--color-kumo-elevated);
  color: var(--text-color-kumo-subtle);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
}
.role-viewer::before {
  background: var(--text-color-kumo-placeholder);
}

/* Main Content Container: max-width 1440px, 24px gutters */
.app-content {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  min-width: 0;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color-kumo-strong);
  letter-spacing: normal;
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-color-kumo-subtle);
  margin-top: 2px;
  line-height: 1.4;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Kumo LayerCard Pattern (Gray rim/header + White body, thin ring with shadow)
   ========================================================================== */

.card {
  background: var(--color-kumo-base);
  box-shadow: var(--shadow-kumo-card);
  border-radius: var(--radius-outer);
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
  max-width: 100%;
  border: none;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color-kumo-strong);
  background: var(--color-kumo-elevated);
  border-bottom: 1px solid var(--color-kumo-line);
  margin: -16px -16px 14px -16px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: normal;
}

.chart-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* Grids: proper min-width 0 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

/* Restrained, Aligned Stat Cards */
.stat-card {
  background: var(--color-kumo-base);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  border-radius: var(--radius-inner);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-color-kumo-subtle);
  font-weight: 500;
  line-height: 1.2;
}

.stat-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-color-kumo-strong);
  line-height: 1.2;
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Resource Tables (Light header, compact 14px rows, subtle hover)
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-inner);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  background: var(--color-kumo-base);
}

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

table.data-table thead th {
  background: var(--color-kumo-elevated);
  color: var(--text-color-kumo-subtle);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-kumo-line);
  white-space: nowrap;
  letter-spacing: normal;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data-table tbody td {
  padding: 9px 12px;
  color: var(--text-color-kumo-default);
  border-bottom: 1px solid var(--color-kumo-hairline);
  vertical-align: middle;
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover td {
  background-color: var(--color-kumo-fill-hover);
}

table.data-table td a {
  color: var(--color-kumo-brand);
  text-decoration: none;
  font-weight: 500;
}

table.data-table td a:hover {
  text-decoration: underline;
}

/* Key-Value Inspector Table */
table.data-table.kv-table {
  border-collapse: separate;
  border-spacing: 0;
}

table.data-table.kv-table th {
  background: var(--color-kumo-elevated) !important;
  color: var(--text-color-kumo-subtle) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  text-transform: none !important;
  padding: 8px 12px !important;
  border-bottom: 1px solid var(--color-kumo-hairline) !important;
  width: 35%;
  white-space: normal;
}

table.data-table.kv-table td {
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text-color-kumo-strong);
  border-bottom: 1px solid var(--color-kumo-hairline);
}

table.data-table.kv-table tr:last-child th,
table.data-table.kv-table tr:last-child td {
  border-bottom: none !important;
}

/* Action buttons in table cells */
table.data-table td .btn {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Badges & Semantic Chips (Concentric, non-pill rectangular tags)
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  background: var(--color-kumo-elevated);
  color: var(--text-color-kumo-subtle);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
}

.badge-COMPLETED, .badge-success, .badge-active {
  background: var(--color-kumo-success-tint);
  color: var(--color-kumo-success);
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.25);
}

.badge-RUNNING {
  background: var(--color-kumo-info-tint);
  color: var(--color-kumo-info);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.badge-PENDING, .badge-PAUSED, .badge-PAUSING {
  background: var(--color-kumo-warning-tint);
  color: var(--color-kumo-warning);
  box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.25);
}

.badge-FAILED {
  background: var(--color-kumo-danger-tint);
  color: var(--color-kumo-danger);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

.badge-CANCELLED, .badge-CANCELLING {
  background: var(--color-kumo-elevated);
  color: var(--text-color-kumo-subtle);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
}

.badge-INTERRUPTED {
  background: #faf5ff;
  color: #7e22ce;
  box-shadow: 0 0 0 1px rgba(126, 34, 206, 0.25);
}

/* ==========================================================================
   Buttons (14px, compact, accessible focus visible, no color transitions)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-inner);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-kumo-brand);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-kumo-contrast);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.btn-primary:hover:not(:disabled) {
  background: #1f2937;
}

.btn-primary:active:not(:disabled) {
  background: #000000;
}

.btn-secondary {
  background: var(--color-kumo-base);
  color: var(--text-color-kumo-default);
  box-shadow: 0 0 0 1px var(--color-kumo-line), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-kumo-fill-hover);
}

.btn-secondary:active:not(:disabled) {
  background: var(--color-kumo-recessed);
}

.btn-danger {
  background: var(--color-kumo-danger-tint);
  color: var(--color-kumo-danger);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-success {
  background: var(--color-kumo-success-tint);
  color: var(--color-kumo-success);
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.25);
}

.btn-success:hover:not(:disabled) {
  background: #d1fae5;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* Button Group / Toolbar */
.btn-group {
  display: inline-flex;
  align-items: center;
  background: var(--color-kumo-elevated);
  padding: 2px;
  border-radius: var(--radius-inner);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  gap: 2px;
}

.btn-group .btn {
  border: none;
  background: transparent;
  color: var(--text-color-kumo-subtle);
  box-shadow: none;
  height: 26px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-group .btn:hover:not(:disabled) {
  color: var(--text-color-kumo-strong);
  background: rgba(255, 255, 255, 0.7);
}

.btn-group .btn.active,
.btn-group .btn-primary {
  background: var(--color-kumo-base);
  color: var(--text-color-kumo-strong);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Form Controls (14px, ringed inputs, focus visible)
   ========================================================================== */

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text-color-kumo-strong);
}

.form-control {
  width: 100%;
  height: 32px;
  padding: 4px 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  border: none;
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  border-radius: var(--radius-inner);
  background: var(--color-kumo-base);
  color: var(--text-color-kumo-strong);
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-kumo-brand);
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  -webkit-appearance: none;
  appearance: none;
}

textarea.code-editor {
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 220px;
  white-space: pre;
  tab-size: 2;
  line-height: 1.45;
  padding: 10px 12px;
  height: auto;
}

input[type="radio"], input[type="checkbox"] {
  accent-color: var(--color-kumo-brand);
  cursor: pointer;
}

/* ==========================================================================
   Segmented Tabs
   ========================================================================== */

.segmented-tabs {
  display: inline-flex;
  align-items: center;
  background: var(--color-kumo-elevated);
  padding: 2px;
  border-radius: var(--radius-inner);
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  gap: 2px;
}

.tab-btn {
  height: 28px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-color-kumo-subtle);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-color-kumo-strong);
}

.tab-btn.active {
  background: var(--color-kumo-base);
  color: var(--text-color-kumo-strong);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Alert Callouts & Warnings
   ========================================================================== */

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-inner);
  margin-bottom: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  border: none;
}

.alert-info {
  background: var(--color-kumo-info-tint);
  color: #1e40af;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.alert-warning {
  background: var(--color-kumo-warning-tint);
  color: #92400e;
  box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.25);
}

.alert-danger {
  background: var(--color-kumo-danger-tint);
  color: #991b1b;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

.alert-success {
  background: var(--color-kumo-success-tint);
  color: #065f46;
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.25);
}

/* Policy Details / Collapsible */
details.policy-details {
  box-shadow: 0 0 0 1px var(--color-kumo-line);
  border-radius: var(--radius-inner);
  padding: 8px 12px;
  background: var(--color-kumo-elevated);
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-color-kumo-subtle);
}

details.policy-details summary::-webkit-details-marker {
  display: none;
}

details.policy-details summary {
  list-style: none;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-color-kumo-strong);
  user-select: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

details.policy-details summary::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-color-kumo-subtle);
  border-bottom: 1.5px solid var(--text-color-kumo-subtle);
  transform: rotate(-45deg);
  margin-right: 2px;
}

details.policy-details[open] summary::before {
  transform: rotate(45deg);
  border-color: var(--color-kumo-brand);
}

details.policy-details[open] summary {
  margin-bottom: 8px;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-color-kumo-subtle);
}

.empty-state svg {
  width: 28px;
  height: 28px;
  stroke: var(--text-color-kumo-subtle);
  stroke-width: 1.5;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text-color-kumo-subtle);
}

/* ==========================================================================
   Reversi 8x8 Board (Tournament Precision Palette)
   ========================================================================== */

.reversi-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
}

.board-frame {
  background: var(--board-frame);
  border-radius: var(--radius-outer);
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  max-width: 100%;
}

.board-coords-x {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 384px;
  max-width: calc(100vw - 84px);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  padding: 3px 0;
}

.board-middle-row {
  display: flex;
  align-items: center;
  max-width: 100%;
}

.board-coords-y {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  height: 384px;
  max-height: calc(100vw - 84px);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  padding: 0 5px;
  align-items: center;
  text-align: center;
}

.reversi-board {
  width: 384px;
  height: 384px;
  max-width: calc(100vw - 84px);
  max-height: calc(100vw - 84px);
  aspect-ratio: 1;
  background-color: var(--board-bg);
  border: 1px solid var(--board-grid);
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 1.5px;
  padding: 1.5px;
  box-sizing: border-box;
}

.board-cell {
  background-color: var(--board-cell);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  user-select: none;
  border-radius: 2px;
}

.board-cell:hover {
  background-color: var(--board-cell-hover);
}

.disc {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  position: relative;
}

.disc-black, .disc.black {
  background: radial-gradient(circle at 35% 32%, #2c2c2e 0%, #151516 65%, #0d0d0e 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.disc-white, .disc.white {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f4f4f6 60%, #e1e1e6 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}

.disc-last-move::after, .disc.last-move::after {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.8);
}

.board-cell.legal-hint::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.board-cell.flip-hint {
  background-color: rgba(37, 99, 235, 0.35);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--color-kumo-contrast);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow-kumo-elevated);
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
}

/* Responsive Layout */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-kumo-elevated);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .app-topbar {
    padding: 0 16px;
  }

  .app-content {
    padding: 16px 16px 36px;
  }

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

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .topbar-title {
    max-width: 180px;
    font-size: 13px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .board-coords-x {
    width: min(280px, calc(100vw - 84px));
    font-size: 10px;
  }

  .board-coords-y {
    height: min(280px, calc(100vw - 84px));
    font-size: 10px;
    padding: 0 3px;
  }

  .reversi-board {
    width: min(280px, calc(100vw - 84px));
    height: min(280px, calc(100vw - 84px));
  }
}
