:root {
  --brand: #b3151a;
  --brand-dark: #8d1015;
  --ink: #1f2328;
  --ink-soft: #5b6570;
  --line: #e2e5ea;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ok: #0f7b4f;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ---------------------------------------------------------------- ログイン画面 */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

.login-card .mark {
  width: 40px; height: 40px;
  margin: 0 auto 18px;
  border-radius: 8px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.03em;
}

.login-card h1 { font-size: 19px; margin: 0 0 6px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 26px; color: var(--ink-soft); font-size: 13px; }

.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  background: #fff; color: #3c4043;
  border: 1px solid #cfd4da; border-radius: 8px;
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.google-btn:hover { background: #f7f8fa; border-color: #b6bcc4; }
.google-btn svg { width: 18px; height: 18px; }

.login-note { margin-top: 20px; font-size: 12px; color: #8a929c; }

/* ------------------------------------------------------------------ アプリ画面 */

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: -.01em; }
.topbar .brand span { color: var(--brand); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--ink-soft); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.panel-head .spacer { flex: 1; }

.tpl-list { list-style: none; margin: 0; padding: 6px; }
.tpl-list li { margin: 0; }
.tpl-list button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 7px;
  padding: 9px 11px; cursor: pointer;
}
.tpl-list button:hover { background: #f2f4f7; }
.tpl-list button[aria-current="true"] { background: #fdf0f0; box-shadow: inset 2px 0 0 var(--brand); }
.tpl-list .name { display: block; font-weight: 600; }
.tpl-list .meta { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }

.editor { display: grid; gap: 16px; }

.field { padding: 14px 16px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.field input[type="text"], .field textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 11px; background: #fff;
}
.field input[type="text"]:focus, .field textarea:focus {
  outline: 2px solid rgba(179, 21, 26, .28); outline-offset: -1px; border-color: var(--brand);
}
.field textarea {
  min-height: 380px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55;
}

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.preview-frame {
  width: 100%; height: 520px; border: 0; border-radius: 0 0 10px 10px; background: #fff;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f2f4f7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #f2f4f7; }

.hint-row { padding: 0 16px 14px; font-size: 12px; color: var(--ink-soft); }
.hint-row code {
  background: #fdf0f0; border: 1px solid #f3d7d8; color: var(--brand-dark);
  border-radius: 4px; padding: 1px 5px; margin-right: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px;
}

.versions { list-style: none; margin: 0; padding: 6px; max-height: 300px; overflow: auto; }
.versions li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px;
}
.versions li:hover { background: #f2f4f7; }
.versions .label { font-weight: 600; font-variant-numeric: tabular-nums; }
.versions .note { color: var(--ink-soft); font-size: 12px; flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: #1f2328; color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--brand); }

.empty { padding: 40px 16px; text-align: center; color: var(--ink-soft); }

/* -------------------------------------------------------------- 言語切り替え */

.langswitch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
.langswitch .lang {
  border: 0; background: none; cursor: pointer;
  padding: 8px 14px; font-weight: 600; font-size: 13px; color: var(--ink-soft);
}
.langswitch .lang + .lang { border-left: 1px solid var(--line); }
.langswitch .lang:hover { background: #f2f4f7; }
.langswitch .lang[aria-pressed="true"] { background: var(--brand); color: #fff; }

.tool-sep { width: 6px; }

.hint-row.note { color: var(--ink); }
.hint-row .badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; margin-right: 6px;
}
.hint-row .badge.ja { background: #fdf0f0; color: var(--brand-dark); }
.hint-row .badge.en { background: #eef2f7; color: #3f5570; }
.hint-row .badge.warn { background: #fff4e5; color: #8a5a00; }
