:root {
  --blue: #1a73e8;
  --blue-hover: #185abc;
  --text: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --surface: #fff;
  --background: #f8fafd;
  --green: #188038;
  --red: #d93025;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--background);
  font: 14px/1.5 Roboto, Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #3c4043;
  text-decoration: none;
  font: 500 21px "Google Sans", Roboto, sans-serif;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc04 0 75%, #ea4335 0);
}
.brand-mark span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  color: #fff;
  background: #4285f4;
  font: 700 17px "Google Sans", sans-serif;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.status { display: flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--muted); font-size: 13px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #f9ab00; }
.status.ready i { background: var(--green); }
.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #5f6368;
  background: transparent;
  text-decoration: none;
}
.icon-button:hover { background: #f1f3f4; }

.main-content { width: min(1180px, calc(100% - 48px)); margin: 0 auto; flex: 1; }
.hero {
  padding: 48px 0 28px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
h1, h2 { font-family: "Google Sans", Roboto, sans-serif; font-weight: 500; margin: 0; }
.hero h1 { font-size: 36px; line-height: 1.25; letter-spacing: -.02em; }
.hero p { margin: 7px 0 0; color: var(--muted); font-size: 16px; }
.text-button {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 20px;
  color: var(--blue);
  background: transparent;
  font-weight: 500;
}
.text-button:hover { background: #e8f0fe; }

.workspace {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.action-card {
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(60,64,67,.05);
}
.card-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.card-icon.blue { color: #1967d2; background: #e8f0fe; }
.card-icon.green { color: #137333; background: #e6f4ea; }
.card-icon.yellow { color: #b06000; background: #fef7e0; }
.action-card h2 { font-size: 24px; line-height: 1.3; }
.action-card > p { min-height: 44px; margin: 6px 0 24px; color: var(--muted); }
form { display: flex; flex-direction: column; gap: 20px; }
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #3c4043;
  font-size: 13px;
  font-weight: 500;
}
label small { color: var(--muted); font-size: 12px; font-weight: 400; }
select, input, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #bdc1c6;
  border-radius: 4px;
  outline: none;
  background: #fff;
}
textarea { min-height: 148px; resize: vertical; }
select:hover, input:hover, textarea:hover { border-color: #80868b; }
select:focus, input:focus, textarea:focus { border: 2px solid var(--blue); padding: 11px 13px; }
.dropzone {
  min-height: 174px;
  padding: 22px;
  border: 1px dashed #9aa0a6;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #f8fafd;
  transition: background .15s, border-color .15s;
}
.dropzone:hover { border-color: var(--blue); background: #f2f7ff; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { color: var(--blue); font-size: 14px; font-weight: 500; }
.dropzone small {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-symbol { color: var(--blue); font-size: 28px; font-weight: 400; }
.primary, .secondary-button {
  min-height: 42px;
  padding: 0 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  text-decoration: none;
  font-weight: 500;
  letter-spacing: .01em;
}
.primary { color: #fff; background: var(--blue); }
.primary:hover { background: var(--blue-hover); box-shadow: 0 1px 2px rgba(60,64,67,.3); }
.primary:disabled { opacity: .65; cursor: wait; }
.secondary-button { color: var(--blue); background: transparent; }
.secondary-button:hover { background: #e8f0fe; }
.character-count { margin-top: -16px; color: var(--muted); text-align: right; font-size: 11px; }
footer {
  width: min(1180px, calc(100% - 48px));
  margin: auto;
  padding: 32px 0;
  display: flex;
  justify-content: space-between;
  color: #80868b;
  font-size: 12px;
}

.back-link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 20px; color: var(--blue); text-decoration: none; font-weight: 500; }
.back-link:hover { background: #e8f0fe; }
.settings-page { width: min(980px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 80px; }
.settings-title { margin-bottom: 32px; }
.settings-title h1 { font-size: 36px; }
.settings-title p { color: var(--muted); font-size: 16px; margin: 8px 0 0; }
.settings-form {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.settings-section {
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(300px, 1.3fr);
  gap: 48px;
  border-bottom: 1px solid var(--line);
}
.settings-copy h2 { font-size: 20px; }
.settings-copy p { margin: 7px 0 0; color: var(--muted); }
.settings-fields { display: flex; flex-direction: column; gap: 22px; }
.access-people { gap: 14px; }
.access-person {
  display: grid;
  grid-template-columns: minmax(90px, .7fr) minmax(130px, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.access-person strong { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.access-person label { gap: 6px; }
.connection-card { min-height: 64px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafd; }
.connection-card > div { min-width: 0; display: flex; flex-direction: column; }
.connection-card strong { font: 500 15px "Google Sans", Roboto, sans-serif; }
.connection-card small { margin-top: 2px; color: var(--muted); }
.connection-indicator { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #9aa0a6; }
.connection-card.connected { border-color: #ceead6; background: #e6f4ea; }
.connection-card.connected .connection-indicator { background: var(--green); }
.copy-field { display: flex; }
.copy-field input { min-width: 0; border-radius: 4px 0 0 4px; background: #f8fafd; }
.copy-field input:focus { position: relative; z-index: 1; }
.copy-button { flex: none; min-width: 68px; border: 1px solid #bdc1c6; border-left: 0; border-radius: 0 4px 4px 0; color: var(--blue); background: #fff; font-weight: 500; }
.copy-button:hover { background: #e8f0fe; }
.connection-actions { display: flex; align-items: center; gap: 8px; }
.danger-button { color: var(--red); }
.danger-button:hover { color: #b3261e; background: #fce8e6; }
.settings-actions {
  min-height: 76px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: #f8fafd;
}
#saveStatus { margin-right: auto; color: var(--green); }
.setup-guide { padding: 20px 32px; border-bottom: 1px solid var(--line); }
.setup-guide details { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.setup-guide summary {
  min-height: 72px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.setup-guide summary::-webkit-details-marker { display: none; }
.setup-guide summary:hover { background: #f8fafd; }
.setup-guide summary > span:nth-child(2) { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.setup-guide summary strong { font: 500 16px "Google Sans", Roboto, sans-serif; }
.setup-guide summary small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.setup-guide-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: #e8f0fe; }
.expand-arrow { flex: none; color: var(--muted); transition: transform .2s ease; }
.setup-guide details[open] .expand-arrow { transform: rotate(180deg); }
.setup-guide-content { padding: 8px 28px 28px 72px; border-top: 1px solid var(--line); color: #3c4043; }
.setup-guide-content h3 { margin: 24px 0 8px; color: var(--text); font: 500 17px "Google Sans", Roboto, sans-serif; }
.setup-guide-content ol { margin: 0; padding-left: 22px; }
.setup-guide-content ul { margin: 6px 0; padding-left: 20px; }
.setup-guide-content li + li { margin-top: 6px; }
.setup-guide-content code { padding: 2px 5px; border-radius: 4px; background: #f1f3f4; font: 12px Consolas, monospace; overflow-wrap: anywhere; }

.lock-screen { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; padding: 20px; background: #fff; }
.lock-screen[hidden] { display: none; }
.unlock-card { width: min(400px, 100%); align-items: center; padding: 40px; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.unlock-card h2 { font-size: 28px; }
.unlock-card p { margin: 0; color: var(--muted); }
.unlock-card .eyebrow { color: var(--blue); font-size: 12px; font-weight: 500; letter-spacing: .08em; }
.unlock-card input { text-align: center; font-size: 22px; letter-spacing: .35em; }
.unlock-card .primary { width: 100%; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 10; max-width: min(520px, calc(100% - 32px)); padding: 13px 18px; border-radius: 4px; color: #fff; background: #3c4043; box-shadow: 0 6px 18px rgba(60,64,67,.3); opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .action-card { display: grid; grid-template-columns: 48px 1fr; column-gap: 20px; }
  .action-card .card-icon { grid-row: 1 / span 2; }
  .action-card > p { min-height: 0; margin-bottom: 24px; }
  .action-card form { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .topbar { min-height: 60px; padding: 0 12px 0 16px; }
  .brand { font-size: 19px; }
  .status { display: none; }
  .main-content { width: calc(100% - 32px); }
  .hero { padding: 28px 0 20px; align-items: start; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 14px; }
  .text-button { display: none; }
  .workspace { gap: 14px; }
  .action-card { padding: 22px 18px; border-radius: 12px; }
  .action-card h2 { font-size: 21px; }
  .dropzone { min-height: 150px; }
  .primary { min-height: 46px; width: 100%; }
  footer { width: calc(100% - 32px); padding: 24px 0; }
  .back-link { font-size: 0; width: 42px; padding: 0; justify-content: center; }
  .settings-page { width: 100%; padding: 28px 16px 100px; }
  .settings-title { margin-bottom: 22px; }
  .settings-title h1 { font-size: 28px; }
  .settings-title p { font-size: 14px; }
  .settings-form { border-radius: 12px; }
  .settings-section { padding: 24px 18px; grid-template-columns: 1fr; gap: 20px; }
  .access-person { grid-template-columns: 1fr; }
  .access-person strong { grid-column: auto; }
  .setup-guide { padding: 18px; }
  .setup-guide summary { padding: 12px; }
  .setup-guide summary small { white-space: normal; }
  .setup-guide-content { padding: 4px 18px 24px; }
  .settings-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; min-height: 72px; padding: 12px 16px; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(60,64,67,.08); }
  .settings-actions .primary { width: auto; }
  .connection-actions { align-items: stretch; flex-direction: column; }
  .connection-actions .primary, .connection-actions .secondary-button { width: 100%; }
  #saveStatus { display: none; }
  .unlock-card { padding: 32px 24px; }
}
