:root {
  --bg: #ffffff;
  --fg: #202124;
  --muted: #5f6368;
  --line: #dfe1e5;
  --surface: #f1f3f4;
  --surface-hover: #e8eaed;
  --accent: #1a73e8;
  --shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  --ok: #188038;
  --err: #d93025;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --line: #5f6368;
    --surface: #303134;
    --surface-hover: #3c4043;
    --accent: #8ab4f8;
    --shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    --ok: #81c995;
    --err: #f28b82;
  }
}

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

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Home ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18vh 16px 32px;
  gap: 26px;
}
.logo {
  font-size: clamp(56px, 12vw, 88px);
  font-weight: 500;
  letter-spacing: -3px;
  user-select: none;
  line-height: 1;
}

.search {
  position: relative;
  width: 100%;
  max-width: 584px;
}
.search input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0 20px 0 50px;
  font-size: 16px;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: box-shadow 0.15s;
}
.search input:hover, .search input:focus { box-shadow: var(--shadow); border-color: transparent; }
.search-icon {
  position: absolute; left: 17px; top: 14px;
  width: 20px; height: 20px;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}

.engine { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: -10px; }
.engine select {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; font: inherit;
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  height: 36px;
  font-size: 14px;
}
.btn:hover { border-color: var(--line); box-shadow: 0 1px 1px rgba(0,0,0,.1); }

.shortcuts {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  max-width: 584px;
}
.shortcuts a {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 96px; padding: 14px 4px;
  border-radius: 8px;
  color: var(--fg); text-decoration: none; font-size: 13px;
}
.shortcuts a:hover { background: var(--surface); }
.shortcuts span {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); font-weight: 600; font-size: 18px; color: var(--accent);
}
.shortcuts a:hover span { background: var(--surface-hover); }

.status { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; margin: 0; text-align: center; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok .dot { background: var(--ok); }
.status.err { color: var(--err); }
.status.err .dot { background: var(--err); }

.logout { margin-top: auto; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; }

/* ---------- Barra di navigazione ---------- */
.bar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.icon {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: none;
}
.icon:hover { background: var(--surface); }
.icon svg, .lock svg {
  width: 18px; height: 18px;
  fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.address {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  height: 36px; margin: 0 4px;
  background: var(--surface);
  border-radius: 18px;
  padding: 0 14px 0 10px;
}
.address:focus-within { background: var(--bg); box-shadow: 0 0 0 2px var(--accent); }
.lock { display: grid; place-items: center; margin-right: 8px; }
.lock svg { stroke: var(--ok); width: 15px; height: 15px; }
.address input {
  flex: 1; min-width: 0;
  border: 0; outline: none; background: none;
  color: var(--fg); font-size: 14px;
}

.notice {
  position: fixed; left: 50%; top: 58px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--fg); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 10;
}

#frame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 560px) {
  #btn-forward, #btn-newtab { display: none; }
  .bar { gap: 0; padding: 6px 4px; }
}

/* ---------- Login ---------- */
.login {
  flex: 1; display: grid; place-items: center; padding: 16px;
}
.login form {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 36px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.login h1 { margin: 0; font-size: 24px; font-weight: 500; text-align: center; }
.login p { margin: 0; color: var(--muted); text-align: center; }
.login input {
  height: 46px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); font-size: 15px; outline: none;
}
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.login button {
  height: 42px; border: 0; border-radius: 6px;
  background: var(--accent); color: var(--bg); font-weight: 600;
}
.login .error { color: var(--err); }
