/* Guppy's Guide unified UI (2026-11-09): light default, dark via
   [data-theme="dark"], shared localStorage key "guppy-theme". */
:root, :root[data-theme="light"] {
  --bg: #f7f8fa; --card: #ffffff; --text: #14181f; --muted: #5c6572;
  --line: #e3e6ec; --input-bg: #ffffff; --chip: #eef1f5;
  --accent: #2563eb; --link: #2563eb; --status: #2563eb;
  --detail-bg: #f4f6fa; --portfolio-bg: #e8effc;
  --badge-lp-bg: #ece7fb; --badge-lp-text: #5b3ea8;
  --badge-div-bg: #fdf0c0; --badge-div-text: #7a5b00;
  --badge-low-bg: #fde3e3; --badge-low-text: #9c2b2b;
  --danger-bg: #fde3e3; --danger-text: #9c2b2b;
  --shadow: 0 1px 3px rgba(16,24,40,.06); --overlay: rgba(20,24,31,.5);
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #121316; --text: #f2f3f5; --muted: #9aa1ab;
  --line: #26282e; --input-bg: #0a0a0b; --chip: #1b1d21;
  --accent: #2563eb; --link: #8fd0ff; --status: #8fd0ff;
  --detail-bg: #0a0a0b; --portfolio-bg: #14263f;
  --badge-lp-bg: #3a2d5c; --badge-lp-text: #cdbcf7;
  --badge-div-bg: #6b5510; --badge-div-text: #ffd94d;
  --badge-low-bg: #5c2d2d; --badge-low-text: #ffb3b3;
  --danger-bg: #5c2d2d; --danger-text: #ffffff;
  --shadow: none; --overlay: rgba(0,0,0,.72);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
header { padding: 24px 20px 8px; max-width: 1120px; margin: 0 auto; position: relative; }
h1 { font-size: 28px; margin: 0 0 6px; padding-right: 340px; line-height: 1.3; }
/* language selector + theme toggle: top-right of the header */
.header-tools { position: absolute; top: 24px; right: 20px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.lang-switch { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lang-switch select { margin-left: 4px; background: var(--input-bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; min-height: 36px; }
.theme-toggle { background: var(--chip); color: var(--text); border: 1px solid var(--line); white-space: nowrap; min-height: 44px; }
@media (max-width: 760px) {
  .header-tools { position: static; justify-content: flex-start; margin-bottom: 10px; }
  h1 { padding-right: 0; font-size: 24px; }
}
.sub { color: var(--muted); margin: 0 0 8px; line-height: 1.5; }
.status { color: var(--status); font-size: 13px; min-height: 18px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 16px; font-size: 15px; cursor: pointer; min-height: 44px; }
button:disabled { opacity: .5; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin: 16px auto; max-width: 1120px; width: calc(100% - 40px); box-shadow: var(--shadow); }
.panel h2 { font-size: 18px; margin: 0 0 10px; }
.anchor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.anchor-card { background: var(--chip); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.anchor-card.main { border: 1px solid var(--accent); }
.anchor-card.warn { border: 1px solid var(--badge-div-text); }
.a-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.a-value { font-size: 19px; font-weight: 700; word-break: break-all; }
.a-note { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.method { margin-top: 10px; }
.method summary, #unpricedDetails summary { cursor: pointer; color: var(--link); }
.method ul { color: var(--text); line-height: 1.65; font-size: 13px; padding-left: 18px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.controls input[type="search"] { flex: 1 1 200px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); font-size: 16px; }
.controls select { padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); font-size: 15px; min-height: 44px; }
.controls input[type="search"]:focus, .controls select:focus, .ca-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.count { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 880px; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.tok { cursor: pointer; }
tr.tok:hover { background: var(--chip); }
.sym { font-weight: 700; color: var(--text); }
.tname { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.badge.lp { background: var(--badge-lp-bg); color: var(--badge-lp-text); }
.badge.div { background: var(--badge-div-bg); color: var(--badge-div-text); }
.badge.lowliq { background: var(--badge-low-bg); color: var(--badge-low-text); }
.detail td { background: var(--detail-bg); color: var(--text); font-size: 12px; line-height: 1.7; }
.detail a, td a { color: var(--link); }
a { color: var(--link); }
footer { max-width: 1120px; margin: 0 auto; padding: 4px 20px 28px; color: var(--muted); font-size: 12px; line-height: 1.6; }
img.icon { width: 20px; height: 20px; border-radius: 50%; vertical-align: middle; margin-right: 6px; background: #fff; }
.ca-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ca-row input { flex: 1 1 260px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); font-size: 16px; font-family: ui-monospace, monospace; }
.tracked-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 8px; }
.tcard { background: var(--chip); border: 1px solid var(--accent); border-radius: 12px; padding: 14px; }
.tcard .t-sym { font-size: 16px; font-weight: 700; }
.tcard .t-price { font-size: 18px; font-weight: 700; margin: 6px 0 2px; }
.tcard .t-line { font-size: 12px; color: var(--muted); line-height: 1.6; }
.tcard .t-remove { margin-top: 8px; background: var(--danger-bg); color: var(--danger-text); }
.portfolio-bar { background: var(--portfolio-bg); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.share-row button { background: var(--chip); color: var(--text); border: 1px solid var(--line); }
.tcard input.amount { width: 100%; margin-top: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); font-size: 16px; }
.tcard .t-value { font-size: 13px; color: var(--status); margin-top: 4px; }
.flash { animation: flashBg 1.6s ease-out; }
@keyframes flashBg { 0% { background: var(--chip); } 100% { background: transparent; } }

/* ---- PC (>=1024px): use the full 1120px width ---- */
@media (min-width: 1024px) {
  .anchor-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tracked-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ca-row input { flex-basis: 420px; }
}

/* ---------- converter modal ---------- */
tr.tok { cursor: pointer; }
.conv-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.conv-sheet { background: var(--card); color: var(--text); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 18px 22px; box-shadow: 0 -8px 40px rgba(0, 0, 0, .5); box-sizing: border-box; }
@media (min-width: 640px) { .conv-overlay { align-items: center; } .conv-sheet { border-radius: 16px; } }
.conv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conv-name { font-size: 13px; color: var(--muted); font-weight: 400; }
.conv-close { background: var(--chip); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; min-height: 44px; font-size: 15px; cursor: pointer; flex-shrink: 0; }
.conv-price-line { margin: 10px 0 2px; font-size: 14px; line-height: 1.7; color: var(--text); }
.conv-fields label { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.conv-fields input { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 12px; font-size: 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); }
.conv-eq { text-align: center; color: var(--muted); margin-top: 8px; font-size: 13px; }
.conv-hint { font-size: 11px; color: var(--muted); margin: 10px 0 0; }
.conv-rate { margin-top: 8px; font-size: 12px; color: var(--muted); }
.conv-detail { margin-top: 12px; font-size: 12px; line-height: 1.7; color: var(--text); word-break: break-all; }
.conv-detail a { color: var(--link); }
.conv-actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.t-conv { margin-top: 8px; margin-right: 6px; }

/* ---------- mobile (<=640px): single column, panels tighten ---------- */
@media (max-width: 640px) {
  header { padding: 20px 16px 8px; }
  .panel { padding: 16px; width: calc(100% - 32px); }
  footer { padding: 4px 16px 28px; }
}

/* ---------- mobile: token table becomes labelled cards ---------- */
@media (max-width: 760px) {
  #tokenTable { min-width: 0; font-size: 13px; }
  #tokenTable thead { display: none; }
  #tokenTable, #tokenTable tbody, #tokenTable tr, #tokenTable td { display: block; width: 100%; }
  #tokenTable tr.tok { padding: 10px 2px 12px; border-bottom: 2px solid var(--line); }
  #tokenTable td { border-bottom: 0; padding: 3px 4px; }
  #tokenTable td.rank { display: none; }
  #tokenTable td.tok-head { padding-bottom: 5px; }
  #tokenTable td.num, #tokenTable td.routecell {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  }
  #tokenTable td.num::before, #tokenTable td.routecell::before {
    content: attr(data-label); color: var(--muted); font-size: 11px; text-align: left; white-space: nowrap;
  }
}
