@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=Syne:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --content-max-width: 840px;
  --page-bg: #f5f5f3;
  --font-title: 'Syne', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'DM Mono', monospace;
  --surface-base: #ffffff;
  --border-base: #dcdad2;
  --text-muted-base: #7f7d75;
  --page-padding-y: 32px;
  --page-padding-x: 16px;
  --panel-padding: 24px;
  --panel-gap: 16px;
  --btn-height: 38px;
  --btn-font-size: 13px;
  --input-height: 46px;
  --intro-title-size: 20px;
  --intro-subtitle-size: 13px;
  --intro-gap: 8px;
  --intro-block-space: 24px;
  --hover-border: #8f8d86;
  --hover-text: #1a1a1a;
  --hover-bg-soft: #f1f0ec;
  --panel-header-bg: #f8f7f4;
}

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

/* =========================
   character.html
   ========================= */
body.page-character {
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --border: #E2E0D8;
  --text-primary: #1A1917;
  --text-secondary: #7A7870;
  --accent: #3D5AFE;

  font-family: var(--font-body);
  background: var(--page-bg);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--page-padding-y) var(--page-padding-x);
}

body.page-character .card {
  background: var(--surface-base);
  width: 100%;
  max-width: var(--content-max-width);
  border: 1px solid var(--border-base);
}

body.page-character .card-header {
  padding: var(--panel-padding);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
}

body.page-character .header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.page-character .header-icon {
  width: 28px;
  height: 28px;
  background: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

body.page-character .header-icon svg {
  width: 16px;
  height: 16px;
  fill: white;
}

body.page-character .header-title {
  font-family: var(--font-title);
  font-size: var(--intro-title-size);
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

body.page-character .clear-btn {
  font-family: var(--font-body);
  font-size: var(--btn-font-size);
  height: var(--btn-height);
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border-base);
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

body.page-character .clear-btn:hover {
  color: var(--hover-text);
  border-color: var(--hover-border);
  background: var(--hover-bg-soft);
}

body.page-character textarea {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--text-primary);
  background: transparent;
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: none;
  outline: none;
  padding: var(--panel-padding);
  display: block;
}

body.page-character textarea::placeholder {
  color: #C4C2BA;
}

body.page-character .stats-bar {
  border-top: 1px solid var(--border-base);
  padding: 0 var(--panel-padding);
  display: flex;
  align-items: stretch;
  min-height: 64px;
}

body.page-character .stat-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 24px 14px 0;
  margin-right: 24px;
  border-right: 1px solid var(--border);
  min-width: 100px;
}

body.page-character .stat-block:last-child {
  border-right: none;
  margin-right: 0;
}

body.page-character .stat-label {
  font-size: 11px;
  color: var(--text-muted-base);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

body.page-character .stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
}

body.page-character .stat-value.highlight {
  color: var(--accent);
}

/* =========================
   ratio.html
   ========================= */
body.page-ratio {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: #1a1a1a;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--page-padding-y) var(--page-padding-x);
}

body.page-ratio .container {
  width: 100%;
  max-width: var(--content-max-width);
}

body.page-ratio h1 {
  font-family: var(--font-title);
  font-size: var(--intro-title-size);
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: var(--intro-gap);
  color: #1a1a1a;
}

body.page-ratio .subtitle {
  font-family: var(--font-body);
  font-size: var(--intro-subtitle-size);
  color: var(--text-muted-base);
  margin-bottom: 0;
  line-height: 1.6;
}

body.page-ratio .ratio-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: var(--intro-block-space);
  flex-wrap: wrap;
}

body.page-ratio .tab-btn {
  font-family: var(--font-body);
  padding: 0 16px;
  height: var(--btn-height);
  border: 1px solid var(--border-base);
  border-radius: 0;
  background: var(--surface-base);
  font-size: var(--btn-font-size);
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}

body.page-ratio .tab-btn:hover {
  border-color: var(--hover-border);
  color: var(--hover-text);
  background: var(--hover-bg-soft);
}

body.page-ratio .tab-btn.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

body.page-ratio .ratio-info {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted-base);
  margin-bottom: var(--intro-block-space);
  height: 16px;
}

body.page-ratio .calc-area {
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: 0;
  padding: var(--panel-padding);
}

body.page-ratio .page-intro {
  margin-bottom: var(--intro-block-space);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-base);
  min-height: 86px;
}

body.page-ratio .inputs-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.page-ratio .input-group {
  flex: 1;
}

body.page-ratio .input-group label {
  font-family: var(--font-title);
  display: block;
  font-size: 11px;
  color: var(--text-muted-base);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

body.page-ratio .input-group input {
  font-family: var(--font-mono);
  width: 100%;
  height: var(--input-height);
  border: 1px solid var(--border-base);
  border-radius: 0;
  font-size: 22px;
  font-weight: 400;
  color: #1a1a1a;
  padding: 0 14px;
  background: #f8f8f6;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

body.page-ratio .input-group input::-webkit-outer-spin-button,
body.page-ratio .input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

body.page-ratio .input-group input:focus {
  outline: none;
  border-color: var(--hover-border);
  background: var(--surface-base);
}

body.page-ratio .input-group input.computed {
  background: #f5f5f3;
  color: #666;
}

body.page-ratio .separator {
  font-size: 18px;
  color: #ccc;
  font-weight: 300;
  padding-top: 20px;
  flex-shrink: 0;
}

body.page-ratio .ratio-display {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

body.page-ratio .ratio-pill {
  font-family: var(--font-mono);
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted-base);
  background: #f5f5f3;
  border: 1px solid var(--border-base);
  border-radius: 0;
  padding: 4px 10px;
}

body.page-ratio .preview-wrap {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid #f0f0ec;
}

body.page-ratio .preview-label {
  font-family: var(--font-title);
  font-size: 11px;
  color: var(--text-muted-base);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

body.page-ratio .preview-box-wrap {
  display: flex;
  align-items: flex-start;
}

body.page-ratio .preview-rect {
  background: #f0f0ec;
  border: 1px solid var(--border-base);
  border-radius: 0;
  transition: all 0.2s;
  max-width: 100%;
}

body.page-ratio .reset-btn {
  font-family: var(--font-body);
  margin-top: 20px;
  width: 100%;
  height: var(--btn-height);
  background: transparent;
  border: 1px solid var(--border-base);
  border-radius: 0;
  font-size: var(--btn-font-size);
  color: var(--text-muted-base);
  cursor: pointer;
  transition: all 0.15s;
}

body.page-ratio .reset-btn:hover {
  color: var(--hover-text);
  border-color: var(--hover-border);
  background: var(--hover-bg-soft);
}

@media (max-width: 400px) {
  body.page-ratio .input-group input {
    font-size: 18px;
    height: 46px;
  }

  body.page-ratio .calc-area {
    padding: 20px 16px 18px;
  }
}

/* =========================
   table.html
   ========================= */
body.page-table {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface2: #f0f0f2;
  --border: #d8d8de;
  --accent: #3b82f6;
  --accent2: #ef4444;
  --accent3: #f59e0b;
  --text: #1a1a2e;
  --text-muted: #9090a0;
  --cell-bg: #ffffff;
  --cell-hover: #f0f6ff;
  --cell-selected: rgba(59,130,246,0.08);
  --cell-selected-border: #3b82f6;
  --th-bg: #eff6ff;
  --th-border: #93c5fd;
  --merged-bg: rgba(239,68,68,0.04);
  --radius: 6px;

  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--page-padding-y) var(--page-padding-x);
}

body.page-table .main-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: visible;
  gap: var(--panel-gap);
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

body.page-table .sidebar {
  width: 100%;
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  padding: 16px;
  gap: 12px 16px;
  overflow: visible;
}

body.page-table .page-intro {
  flex: 1 1 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-base);
  min-height: 86px;
}

body.page-table .page-title {
  font-family: var(--font-title);
  font-size: var(--intro-title-size);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #1a1a1a;
  margin-bottom: var(--intro-gap);
}

body.page-table .page-subtitle {
  font-family: var(--font-body);
  font-size: var(--intro-subtitle-size);
  color: var(--text-muted-base);
  line-height: 1.6;
}

body.page-table .sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
  flex: 1 1 220px;
}

body.page-table .sidebar-label {
  font-family: var(--font-title);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted-base);
}

body.page-table .size-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.page-table .size-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.page-table .size-control label {
  font-size: 11px;
  color: var(--text-muted-base);
}

body.page-table .size-control input[type=number] {
  background: #f8f8f6;
  border: 1px solid var(--border-base);
  color: var(--text);
  border-radius: 0;
  padding: 6px 8px;
  font-size: 14px;
  font-family: var(--font-mono);
  height: var(--input-height);
  width: 100%;
}

body.page-table .size-control input:focus {
  outline: none;
  border-color: var(--hover-border);
}

body.page-table .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  height: var(--btn-height);
  border-radius: 0;
  border: 1px solid var(--border-base);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--btn-font-size);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

body.page-table .btn:hover {
  border-color: var(--hover-border);
  color: var(--hover-text);
  background: var(--hover-bg-soft);
}

body.page-table .btn:active {
  transform: scale(0.97);
}

body.page-table .btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

body.page-table .btn.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

body.page-table .btn.danger {
  border-color: var(--accent2);
  color: var(--accent2);
}

body.page-table .btn.danger:hover {
  background: rgba(244,114,182,0.1);
}

body.page-table .btn.warn {
  border-color: var(--accent3);
  color: var(--accent3);
}

body.page-table .btn.warn:hover {
  background: rgba(251,191,36,0.1);
}

body.page-table .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

body.page-table .btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.page-table .mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-title);
  border: 1px solid var(--border-base);
  background: var(--surface2);
  margin-bottom: 4px;
}

body.page-table .sidebar > .mode-badge {
  flex: 1 1 100%;
  margin-top: 2px;
}

body.page-table .mode-badge.text-mode {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(110,231,183,0.06);
}

body.page-table .dot {
  width: 7px;
  height: 7px;
  border-radius: 0;
  background: currentColor;
}

body.page-table .canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  gap: var(--panel-gap);
}

body.page-table .panel,
body.page-table .output-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: 0;
  overflow: hidden;
  min-height: 0;
}

body.page-table .panel-header,
body.page-table .output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-base);
  background: var(--panel-header-bg);
  flex-shrink: 0;
}

body.page-table .panel-title,
body.page-table .output-title {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted-base);
}

body.page-table .table-wrapper {
  flex: 1;
  overflow: auto;
  padding: var(--panel-padding);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

body.page-table #editor-table {
  border-collapse: collapse;
  user-select: none;
  min-width: 300px;
}

body.page-table #editor-table td,
body.page-table #editor-table th {
  border: 1px solid var(--border-base);
  min-width: 80px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  position: relative;
  cursor: default;
  background: var(--cell-bg);
  transition: background 0.1s;
}

body.page-table #editor-table th {
  background: var(--th-bg);
  border-color: var(--th-border);
}

body.page-table #editor-table td:hover,
body.page-table #editor-table th:hover {
  background: var(--cell-hover);
}

body.page-table #editor-table td.selected,
body.page-table #editor-table th.selected {
  background: var(--cell-selected) !important;
  border-color: var(--cell-selected-border) !important;
  outline: 1px solid var(--cell-selected-border);
  outline-offset: -1px;
}

body.page-table .cell-inner {
  width: 100%;
  height: 100%;
  min-height: 40px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-family: var(--font-body);
  word-break: break-word;
  white-space: pre-wrap;
}

body.page-table .cell-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  resize: none;
  padding: 0;
  line-height: 1.4;
}

body.page-table td.merged-master,
body.page-table th.merged-master {
  background: var(--merged-bg) !important;
}

body.page-table .output-code {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: #2563eb;
  white-space: pre;
  background: transparent;
}

body.page-table .copy-btn {
  padding: 4px 12px;
  height: 30px;
  border-radius: 0;
  border: 1px solid var(--border-base);
  background: var(--surface-base);
  color: var(--text);
  font-size: var(--btn-font-size);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}

body.page-table .copy-btn:hover {
  border-color: var(--hover-border);
  color: var(--hover-text);
  background: var(--hover-bg-soft);
}

body.page-table .toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 0;
  font-weight: 600;
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.2s;
  pointer-events: none;
  z-index: 100;
}

body.page-table .toast.show {
  opacity: 1;
  transform: none;
}

body.page-table ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

body.page-table ::-webkit-scrollbar-track {
  background: transparent;
}

body.page-table ::-webkit-scrollbar-thumb {
  background: var(--border-base);
  border-radius: 0;
}

body.page-table .help-text {
  font-size: 11px;
  color: var(--text-muted-base);
  line-height: 1.6;
}

body.page-table .row-col-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
