/* ==========================================================
   Phonological Rule Editor - スイス・スタイル (Swiss Typographic Style)
   Design Principles:
   - Rational Typography (Noto Sans & Noto Sans JP, JetBrains Mono)
   - Zero Corner Radii (border-radius: 0)
   - Zero Artificial Shadows (box-shadow: none)
   - High Contrast Precision Layout (Pure Black & White with Swiss Red #e11d48)
   ========================================================== */

:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-header: #18181b;
  --text-header: #ffffff;
  --bg-empty: #fcfcfc;

  --border-strong: #000000;
  --border-mid: #27272a;
  --border-light: #d4d4d8;
  --border-subtle: #e4e4e7;

  --text-main: #09090b;
  --text-muted: #52525b;
  --text-dim: #71717a;

  --accent-red: #e11d48;

  --font-main: "Noto Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-ui: var(--font-main);
  --font-mono: "JetBrains Mono", "Menlo", "Consolas", monospace;

  /* Backward-compatible aliases */
  --swiss-white: #ffffff;
  --swiss-bg: #ffffff;
  --swiss-surface: #ffffff;
  --swiss-surface-hover: #f4f4f5;
  --swiss-border: var(--border-light);
  --swiss-border-dark: var(--border-strong);
  --swiss-black: var(--text-main);
  --swiss-gray-dark: var(--text-muted);
  --swiss-gray-medium: var(--text-muted);
  --swiss-gray-light: var(--text-dim);
  --swiss-gray-subtle: var(--bg-subtle);
  --swiss-red: var(--accent-red);
  --font-sans: var(--font-main);
}

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

html {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body {
  width: 100%;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: auto;
  background-color: var(--bg-page);
  padding: 0 16px 40px;
}

.app-container {
  max-width: 1600px;
  margin: 0 auto;
}

/* Sticky Header Container */
.sticky-header-container {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-page);
  border-bottom: 2px solid var(--border-strong);
  padding: 10px 0 8px;
  margin-bottom: 16px;
}

.header-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.title-wrap {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Swiss Language Switcher (JA / EN) */
.lang-switch {
  display: inline-flex;
  align-items: center;
  height: 26px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  overflow: hidden;
  user-select: none;
}

.lang-btn {
  background: #ffffff;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 10px;
  height: 100%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.1s, color 0.1s;
}

.lang-btn:first-child {
  border-right: 1px solid var(--border-strong);
}

.lang-btn:hover:not(.active) {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.lang-btn.active {
  background: var(--text-main);
  color: #ffffff;
  cursor: default;
}

/* Tier 2: Action Toolbar */
.header-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.control-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Swiss Select */
.swiss-select {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  height: 26px;
  padding: 0 24px 0 8px;
  background-color: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  color: var(--text-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23000000' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  outline: none;
}

.swiss-select:focus {
  border-width: 2px;
  padding-left: 7px;
}

/* Swiss Buttons */
.btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.swiss-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  height: 26px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  gap: 6px;
  transition: background-color 0.1s, color 0.1s;
}

.swiss-btn:hover {
  background: var(--text-main);
  color: #ffffff;
}

.swiss-btn:active {
  background: var(--border-mid);
  color: #ffffff;
}

.swiss-btn.btn-black,
.swiss-btn-primary {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.swiss-btn.btn-black:hover,
.swiss-btn-primary:hover {
  background: var(--border-mid);
  color: #ffffff;
}

.swiss-btn.btn-help {
  font-weight: 800;
  padding: 0 10px;
  background: #ffffff;
  color: var(--text-main);
}

.mini-header-btn {
  height: 22px;
  padding: 0 8px;
  font-size: 10px;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid #ffffff;
}

.mini-header-btn:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.btn-svg-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Toggle Group (Operator: → vs >) */
.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  border-radius: 0;
  height: 26px;
  overflow: hidden;
}

.toggle-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
  height: 100%;
  background: #ffffff;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-btn:hover:not(.active) {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.toggle-btn.active {
  background: var(--text-main);
  color: #ffffff;
}

/* Status Ticker */
.status-ticker {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  padding: 5px 8px;
  margin-top: 8px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--border-strong);
  min-height: 24px;
}

.status-symbol {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  min-width: 32px;
}

.status-name {
  font-weight: 700;
  color: var(--text-main);
}

.status-desc {
  font-weight: 400;
  color: var(--text-muted);
}

/* Swiss Section & Header */
.swiss-section {
  border: 1px solid var(--border-strong);
  background: #ffffff;
  border-radius: 0;
  overflow: hidden;
}

.swiss-section-header {
  background: var(--bg-header);
  color: var(--text-header);
  padding: 5px 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.swiss-section-header .sec-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.swiss-section-header .sub {
  font-size: 9.5px;
  font-weight: 500;
  color: #a1a1aa;
}

/* Toast Notification (matching ipa-keyboard) */
#toast,
.swiss-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #000000;
  color: #ffffff;
  border: 1px solid #3f3f46;
  padding: 8px 20px;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10001;
}

#toast.visible,
#toast.show,
.swiss-toast.visible,
.swiss-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modal Backdrop & Box */
.modal-backdrop,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.active,
.modal-backdrop.open,
.modal-overlay.active,
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #ffffff;
  border: 2px solid var(--border-strong);
  border-radius: 0;
  width: 92%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 2px solid var(--border-strong);
  background: var(--bg-header);
  color: #ffffff;
}

.modal-title {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #ffffff;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.12s ease;
}

.modal-close:hover {
  color: var(--accent-red);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-main);
}

.modal-body h3 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-main);
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 4px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin-bottom: 10px;
}

.modal-body ul {
  margin-left: 20px;
  margin-bottom: 14px;
}

.modal-body li {
  margin-bottom: 4px;
}

.modal-body kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: #f4f4f5;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  color: var(--text-main);
}

.modal-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 0;
  color: var(--text-main);
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main) !important;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  background: #f4f4f5;
  border: 1px solid var(--border-mid);
  border-radius: 0;
  transition: background-color 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.modal-link:hover {
  background: var(--text-main);
  color: #ffffff !important;
  border-color: var(--text-main);
}

.modal-link:hover .modal-link-icon {
  fill: #ffffff;
}

.modal-link-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -1px;
}
