:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #1f2933; --muted: #637083; --line: #dde3ea;
  --green: #0b6e4f; --green-bg: #e6f4ee; --blue: #1a5fb4; --blue-bg: #e8f0fb;
  --warn: #a05a00; --warn-bg: #fff3dc; --red: #b42318; --red-bg: #fde8e6; --gray-bg: #eef1f4;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.7;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif; font-size: 15px; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 20px; }

.top { background: #fff; border-bottom: 1px solid var(--line); padding: 26px 0 20px; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .08em; color: var(--green); font-weight: 700; }
h1 { margin: 2px 0 8px; font-size: 28px; line-height: 1.3; }
.lead { margin: 0 0 6px; max-width: 1100px; }
.note { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 1100px; }
.note a { color: var(--blue); }

.controls { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 18px 0 14px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center; }
.btn { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--gray-bg); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.btn.primary:hover { background: #09593f; }
.btn.warn { border-color: #e6c27a; background: var(--warn-bg); color: var(--warn); }
.btn.ghost { color: var(--muted); }
.btn[hidden] { display: none; }
.btn.on { background: var(--blue-bg); border-color: #9ec0ea; color: var(--blue); font-weight: 700; }
select { font: inherit; font-size: 13.5px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; max-width: 100%; }
.status { margin: 4px 0 0; padding: 8px 12px; background: var(--blue-bg); color: #123e75; border-radius: 8px; font-size: 14px; }
.status.ok { background: var(--green-bg); color: #08523b; }
.status.err { background: var(--red-bg); color: #8a1a10; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 1200px) {
  .grid { grid-template-columns: 350px minmax(0, 1fr); grid-template-areas: "gmail sheet" "gmail drive"; align-items: start; }
  #gmailPanel { grid-area: gmail; }
  #sheetPanel { grid-area: sheet; }
  #drivePanel { grid-area: drive; }
  .tree { column-width: 330px; column-gap: 24px; max-height: 420px; }
  .tree > ul > li { break-inside: auto; }
  .maillist { max-height: 1060px; }
}
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 14px; }
@media (min-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.panel h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel h2 small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: #d93025; } .dot.green { background: #188038; } .dot.yellow { background: #f9ab00; }
.muted { color: var(--muted); font-size: 13.5px; }

/* Gmail */
.maillist { list-style: none; margin: 0; padding: 0; max-height: 560px; overflow: auto; }
.mail { border-bottom: 1px solid var(--line); padding: 8px 4px; cursor: pointer; }
.mail:last-child { border-bottom: 0; }
.mail:hover { background: #fafbfc; }
.mail .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.mail .from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--ink); }
.mail .subj { font-size: 14px; margin: 1px 0 3px; word-break: break-all; }
.mail .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--gray-bg); color: var(--muted); white-space: nowrap; }
.chip.done { background: var(--green-bg); color: var(--green); }
.chip.err { background: var(--red-bg); color: var(--red); }
.chip.review { background: var(--warn-bg); color: var(--warn); }
.chip.att { background: var(--blue-bg); color: var(--blue); }
.mail.pending .subj { font-weight: 700; }
.mail .body { display: none; margin-top: 6px; padding: 8px 10px; background: #f8f9fb; border-radius: 6px; font-size: 13px; white-space: pre-wrap; word-break: break-all; }
.mail.open .body { display: block; }

/* Sheet */
.menubar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 6px; background: #f1f3f4; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: 0; font-size: 13px; }
.menubar .mtitle { font-weight: 700; margin-right: 6px; color: #3c4043; }
.menubar button { font: inherit; font-size: 12.5px; border: 0; background: transparent; padding: 3px 8px; border-radius: 6px; cursor: pointer; color: #202124; }
.menubar button:hover { background: #dfe3e7; }
.menubar .sep { width: 1px; height: 16px; background: #c9ced3; margin: 0 2px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border: 1px solid var(--line); border-bottom: 0; padding: 4px 6px 0; background: #fff; }
.tab { font: inherit; font-size: 13px; border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 5px 12px; border-radius: 6px 6px 0 0; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--green-bg); color: var(--green); font-weight: 700; border-color: #b9dccd; }
.tab .n { font-size: 11px; margin-left: 4px; color: var(--muted); }
.tablewrap { border: 1px solid var(--line); overflow: auto; max-height: 520px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { border: 1px solid #e6eaef; padding: 4px 8px; text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #f1f5f9; position: sticky; top: 0; z-index: 1; font-weight: 700; }
td.wrapcell { white-space: normal; min-width: 220px; word-break: break-all; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td[contenteditable="true"] { background: #fffef5; cursor: text; outline: none; }
td[contenteditable="true"]:focus { background: #fff9c4; box-shadow: inset 0 0 0 2px #f0c000; }
tr.new td { animation: flash 2.2s ease-out; }
@keyframes flash { from { background: #fff4b8; } to { background: transparent; } }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.review { background: var(--warn-bg); color: var(--warn); }
.empty { padding: 22px; color: var(--muted); text-align: center; }
.hint { padding: 6px 10px; font-size: 12.5px; color: var(--muted); background: #fafbfc; border-top: 1px solid var(--line); }

/* Drive */
.tree { font-size: 13.5px; max-height: 590px; overflow: auto; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px dashed #d5dbe2; }
.tree > ul { padding-left: 0; border-left: 0; }
.tree li { padding: 2px 0; word-break: break-all; }
.tree .f { font-weight: 700; }
.tree .file small { color: var(--muted); margin-left: 4px; }
.tree .file.new { background: #fff4b8; border-radius: 4px; }
.tree .empty { padding: 14px; }

/* out mails / tests */
.outlist { max-height: 300px; overflow: auto; }
.out { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.out b { display: block; font-size: 13.5px; }
.out pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-all; font: inherit; color: var(--muted); }
.testlist { margin: 0; padding-left: 0; list-style: none; max-height: 300px; overflow: auto; font-size: 13px; }
.testlist li { padding: 2px 0 2px 22px; position: relative; }
.testlist li::before { content: "✓"; position: absolute; left: 2px; color: var(--green); font-weight: 700; }
.testlist li.ng::before { content: "✗"; color: var(--red); }

.prose { margin-top: 14px; }
.steps { margin: 0 0 8px; padding-left: 22px; }
.steps li { margin: 5px 0; }
.code { max-height: 520px; overflow: auto; background: #101826; color: #e5ecf6; padding: 14px; border-radius: 8px; font-size: 12.5px; line-height: 1.6; tab-size: 2; }
summary { cursor: pointer; color: var(--blue); }
.foot { margin: 22px 0; color: var(--muted); font-size: 12.5px; }

@media (min-width: 1200px) {
  .maillist { max-height: 760px; }
  .tree { max-height: 400px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 22px; }
  .btn { font-size: 13px; padding: 7px 10px; }
  select { width: 100%; }
}
