:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #5f6368;
  --line: #e6e8ee;
  --blue: #1a73e8;
  --blue-soft: #d2e3fc;
  --sidebar: #eaf1fb;
  --danger: #c5221f;
  --star: #f4b400;
  --unread: #1a73e8;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.15), 0 2px 6px rgba(60, 64, 67, 0.08);
  --radius: 16px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); }

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 500px at 10% -10%, #d2e3fc 0%, transparent 50%),
    radial-gradient(900px 400px at 100% 0%, #e8f0fe 0%, transparent 45%),
    var(--bg);
}

.auth-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: var(--panel);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(32, 33, 36, 0.12);
}

.auth-hero {
  padding: 48px 40px;
  background: linear-gradient(160deg, #1a73e8, #174ea6);
  color: white;
}

.auth-hero h1 { margin: 0 0 12px; font-size: 42px; letter-spacing: -0.04em; }
.auth-hero p { margin: 0; opacity: 0.92; line-height: 1.5; max-width: 36ch; }
.auth-hero ul { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.auth-hero li { opacity: 0.95; }

.auth-form { padding: 40px 36px; }
.auth-form h2 { margin: 0 0 8px; font-size: 28px; }
.tabs { display: flex; gap: 8px; margin: 18px 0 22px; }
.tabs button {
  border: 0;
  background: #eef2f7;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
}
.tabs button.active { background: var(--blue-soft); color: #174ea6; font-weight: 600; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafbfe;
}
.field:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.addr-row { display: flex; align-items: center; gap: 8px; }
.addr-row .field { flex: 1; }
.suffix { color: var(--muted); white-space: nowrap; }

.primary {
  margin-top: 20px;
  width: 100%;
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 600;
}
.primary:disabled { opacity: 0.6; cursor: default; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 14px; }

.shell { height: 100%; display: grid; grid-template-rows: 64px 1fr; }
.topbar {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--blue); color: white; display: grid; place-items: center; font-size: 18px;
}
.search {
  width: min(720px, 100%);
  border: 0;
  background: #eaf1fb;
  border-radius: 999px;
  padding: 12px 18px;
}
.search:focus { outline: 2px solid var(--blue-soft); background: white; box-shadow: var(--shadow); }
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #188038; color: white; display: grid; place-items: center; font-weight: 700;
}
.ghost { border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 999px; }
.ghost:hover { background: #e8eaed; }

.workspace { display: grid; grid-template-columns: 200px 280px minmax(0, 1fr); min-height: 0; }
.sidebar { padding: 8px 12px 24px; }
.compose {
  width: 100%;
  border: 0;
  background: #c2e7ff;
  color: #001d35;
  border-radius: 16px;
  padding: 16px 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.nav { display: grid; gap: 2px; }
.nav button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 16px;
  border-radius: 0 20px 20px 0;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
}
.nav button.active { background: var(--blue-soft); font-weight: 700; color: #174ea6; }
.badge { color: var(--muted); font-size: 12px; }

.list, .reader { background: var(--panel); min-height: 0; overflow: auto; min-width: 0; }
.list { border-right: 1px solid var(--line); overflow-x: hidden; }
.mail-row {
  width: 100%;
  max-width: 100%;
  border: 0;
  border-bottom: 1px solid #f1f3f4;
  background: white;
  text-align: left;
  padding: 12px 16px 12px 12px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
}
.mail-row.unread { background: #e8f0fe; }
.mail-row.selected { background: #d2e3fc; }
.mail-main {
  border: 0;
  background: transparent;
  text-align: left;
  min-width: 0;
  width: 100%;
  padding: 0;
}
.mail-row strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star { border: 0; background: transparent; color: #dadce0; font-size: 18px; padding: 0; }
.star.on { color: var(--star); }
.empty { padding: 48px 24px; color: var(--muted); text-align: center; }

.reader {
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.reader h2 { margin: 0 0 6px; font-size: 20px; }
.meta { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 10px; }
.from-line { font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.chip { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 7px 12px; }
.body { white-space: pre-wrap; line-height: 1.65; font-size: 15px; overflow: auto; flex: 1; }
.body a { color: var(--blue); word-break: break-all; }
.confirm-btn {
  display: inline-block;
  margin: 4px 0 10px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 16px;
  align-self: flex-start;
  flex-shrink: 0;
}
.html-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: calc(100vh - 190px);
  height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.apps {
  padding: 28px 32px 80px;
  overflow: auto;
  background: var(--panel);
}
.apps h2 { margin: 0 0 8px; }
.apps h3 { margin: 28px 0 10px; }
.apps ol { padding-left: 18px; line-height: 1.6; }
.apps code, .copybox {
  display: block;
  background: #f1f3f4;
  border-radius: 10px;
  padding: 10px 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
}
.dns { width: 100%; border-collapse: collapse; font-size: 13px; }
.dns th, .dns td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.app-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.app-pills span { background: var(--blue-soft); color: #174ea6; border-radius: 999px; padding: 6px 10px; font-size: 13px; }

.composer {
  position: fixed;
  right: 24px;
  bottom: 0;
  width: min(560px, calc(100vw - 24px));
  background: white;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 8px 28px rgba(32,33,36,.28);
  overflow: hidden;
  z-index: 5;
}
.composer header {
  background: #404040;
  color: white;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.composer header button { color: white; }
.composer .row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
}
.composer input, .composer textarea {
  width: 100%;
  border: 0;
  padding: 10px 4px;
  resize: none;
}
.composer textarea { min-height: 180px; padding: 12px; }
.composer footer { display: flex; gap: 8px; padding: 10px 12px 12px; }
.send { border: 0; background: var(--blue); color: white; border-radius: 999px; padding: 8px 18px; font-weight: 600; }

.mail-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 8;
  border: 0;
  background: #202124;
  color: white;
  border-radius: 999px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 48px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .auth-card, .workspace, .topbar { grid-template-columns: 1fr; }
  .auth-hero, .sidebar { display: none; }
  .workspace.show-read .list, .workspace.show-list .reader { display: none; }
}
