:root {
  --blue: #0b57d0;
  --blue-hover: #0842a0;
  --compose: #c2e7ff;
  --compose-hover: #a8d7f7;
  --bg: #f6f8fc;
  --sidebar: #f6f8fc;
  --card: #ffffff;
  --text: #1f1f1f;
  --muted: #5f6368;
  --line: #e3e5e8;
  --danger: #c5221f;
  --ok: #0d7a3f;
  --shadow: 0 1px 3px rgba(60, 64, 67, 0.15), 0 4px 8px rgba(60, 64, 67, 0.08);
  --radius: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-right {
  margin-left: auto;
}

.icon-btn {
  border: 0;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: #f1f3f4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #0b57d0, #4285f4);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.15rem;
  font-weight: 600;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 24px;
  padding: 0 16px;
  height: 46px;
  color: var(--muted);
}

.search input {
  border: 0;
  background: transparent;
  width: 100%;
  outline: none;
  color: var(--muted);
}

.sim-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a5a00;
  background: #fff3cd;
  border: 1px solid #ffe08a;
  padding: 4px 10px;
  border-radius: 999px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #7b1fa2;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 0;
}

.sidebar {
  padding: 16px 12px 24px;
  background: var(--sidebar);
}

.compose-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: var(--compose);
  color: #001d35;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.compose-btn:hover {
  background: var(--compose-hover);
}

.folders {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #202124;
  text-align: left;
  padding: 10px 16px;
  border-radius: 0 24px 24px 0;
  cursor: pointer;
}

.folder .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.folder:hover {
  background: #e7e8eb;
}

.folder.is-active {
  background: #d3e3fd;
  font-weight: 700;
  color: var(--blue);
}

.sidebar-note {
  margin: 24px 8px 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.main {
  padding: 20px 24px 32px;
  min-width: 0;
}

.panel.is-hidden {
  display: none;
}

.compose-card,
.empty-state {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 860px;
}

.compose-card {
  padding: 28px 28px 22px;
}

.compose-head h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.compose-head p {
  margin: 0 0 22px;
  color: var(--muted);
}

.field {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 16px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.field label {
  padding-top: 10px;
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.12);
}

.field textarea {
  resize: vertical;
  min-height: 220px;
  line-height: 1.5;
}

.field-body {
  border-bottom: 0;
  align-items: start;
}

.error {
  grid-column: 2;
  min-height: 0;
  color: var(--danger);
  font-size: 0.8rem;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
  background: #fff8f8;
}

.attachments {
  margin: 8px 0 4px 136px;
}

.attachments-title {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

#attachment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eef4ff;
  border: 1px solid #d3e3fd;
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  font-size: 0.85rem;
}

.chip button {
  border: 0;
  background: transparent;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
}

.chip button:hover {
  background: #d3e3fd;
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 8px;
}

.send-btn {
  border: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 24px;
  cursor: pointer;
}

.send-btn:hover {
  background: var(--blue-hover);
}

.attach-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
}

.attach-btn:hover,
.ghost-btn:hover {
  background: #f1f3f4;
  color: var(--text);
}

.attach-btn input {
  display: none;
}

.empty-state {
  padding: 72px 32px;
  text-align: center;
  margin: 24px auto;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e8f0fe;
  color: var(--blue);
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0 auto 24px;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.55;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.overlay.is-hidden {
  display: none;
}

.sending-box,
.success-box {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  padding: 32px;
  width: min(520px, 100%);
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid #d3e3fd;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.success-check {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e6f4ea;
  color: var(--ok);
}

.success-box h2 {
  margin: 0 0 6px;
}

.success-sub {
  margin: 0 0 18px;
  color: var(--muted);
}

.summary {
  text-align: left;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 20px;
}

.summary div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.92rem;
}

.summary dt {
  color: var(--muted);
  margin: 0;
}

.summary dd {
  margin: 0;
  word-break: break-word;
}

@media (max-width: 860px) {
  .search {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: absolute;
    top: 62px;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 8;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    display: block;
  }

  .field,
  .attachments {
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .error {
    grid-column: 1;
  }

  .compose-card {
    padding: 20px;
  }
}
