:root {
  --bg: #14161f;
  --card: #1e2130;
  --ink: #e7e9f2;
  --muted: #9aa0b8;
  --line: #2e3242;
  --brand: #11131b;
  --accent: #6b78ff;
  --accent-ink: #ffffff;
  --danger: #ef5a4d;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Zen Maru Gothic", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ---- header ---- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-size: 1.05rem; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.count-badge { font-size: .85rem; color: #8b91ad; }

/* ---- buttons ---- */
.btn {
  font-family: inherit; font-size: .95rem; font-weight: 500;
  border: none; border-radius: 999px; padding: 8px 16px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  transition: filter .15s, background .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: rgba(255,255,255,.1); color: #e7e9f2; }
.btn-ghost:hover { filter: brightness(1.25); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---- views ---- */
.main { max-width: 640px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }

/* ---- login ---- */
.login-card {
  max-width: 380px; margin: 8vh auto 0; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 24px; text-align: center;
  border: 1px solid var(--line);
}
.login-icon { font-size: 2.6rem; }
.login-title { margin: 6px 0 2px; font-size: 1.4rem; }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: .92rem; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }

input, textarea, select {
  font-family: inherit; font-size: 1rem; color: var(--ink);
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #161925;
}
input::placeholder, textarea::placeholder { color: #6a7090; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; }

/* ---- list controls ---- */
.search-row { margin-bottom: 14px; }

/* ---- cards (辞書カード：1列で読みやすく) ---- */
.word-grid { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card); border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line); transition: border-color .15s, transform .1s;
  cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card:active { transform: scale(.997); }

.card-body { padding: 12px 15px; display: flex; flex-direction: column; gap: 5px; }
.card-word { font-weight: 700; font-size: 1.08rem; word-break: break-word; }
.card-word ruby { ruby-position: over; }
.card-word rt { font-weight: 400; font-size: .6em; color: var(--muted); user-select: none; }
.card-meaning { font-size: .92rem; color: var(--ink); word-break: break-word; }
.card-example {
  font-size: .84rem; color: var(--muted); word-break: break-word;
  border-top: 1px dashed var(--line); padding-top: 5px; margin-top: 2px;
}

/* ---- form ---- */
.word-form {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px; display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--line);
}
.form-title { margin: 0 0 4px; font-size: 1.2rem; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--muted); }
.field input, .field textarea { color: var(--ink); }
.req { color: var(--danger); font-size: .72rem; }
.field-hint { font-size: .78rem; color: var(--muted); min-height: 1em; }

.fetch-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: -4px; }
.fetch-row .btn-ghost { background: #2a2f45; }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.form-actions .spacer { flex: 1; }

/* ---- empty ---- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: .95rem; }

/* ---- backup menu ---- */
.backup-menu {
  position: fixed; z-index: 110; display: flex; flex-direction: column;
  background: #262b45; border-radius: 12px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); min-width: 220px;
}
.backup-menu button {
  background: none; border: none; color: #e7e9f2; text-align: left;
  padding: 10px 12px; border-radius: 8px; font-size: .9rem; cursor: pointer;
}
.backup-menu button:hover { background: rgba(255,255,255,.1); }

/* ---- banner ---- */
.banner {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #2b3050; color: #fff; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: .9rem; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90%;
}
.banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner-error { background: var(--danger); }
.banner-success { background: #28b487; color: #06281d; }

/* ---- undo banner ---- */
.undo-banner {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #2b3050; color: #fff; padding: 10px 12px 10px 18px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: .9rem; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90%;
  display: flex; align-items: center; gap: 10px;
}
.undo-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.undo-banner button {
  background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 999px;
  padding: 5px 12px; font-size: .85rem; cursor: pointer; flex-shrink: 0;
}
.undo-banner button:hover { background: rgba(255,255,255,.28); }
