:root {
  --ink: #182026;
  --muted: #62717b;
  --paper: #fff8ec;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(24, 32, 38, 0.13);
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --sun: #f2b84b;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(33, 44, 52, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(242, 184, 75, 0.4), transparent 30rem),
    radial-gradient(circle at 90% 8%, rgba(15, 118, 110, 0.24), transparent 26rem),
    linear-gradient(135deg, #fff8ec, #f3efe2 52%, #dfeadf);
}

body:has(.client:not(.hidden)) {
  overflow: hidden;
}

.language-switcher {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 30;
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(33, 44, 52, 0.14);
  backdrop-filter: blur(16px);
}

.language-button {
  min-width: 2.45rem;
  padding: 0.38rem 0.62rem;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font: 700 0.76rem/1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.language-button:hover,
.language-button.is-active {
  background: var(--accent);
  color: white;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.78rem 1.2rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.24);
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.secondary {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.secondary:hover {
  background: white;
}

.small {
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.danger {
  color: var(--danger);
}

.shell {
  min-height: 100vh;
}

.key-panel,
.login-panel,
.accounts-panel {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 430px;
  gap: 2rem;
  align-items: center;
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.92;
  max-width: 780px;
  letter-spacing: -0.06em;
}

.hero p {
  max-width: 560px;
  font-size: 1.15rem;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.card {
  display: grid;
  gap: 1rem;
  padding: 1.3rem;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.key-card textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: none;
}

.key-input-wrap {
  position: relative;
  display: block;
}

.key-input-wrap textarea {
  padding-right: 3.6rem;
}

.icon-copy-button {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  box-shadow: none;
}

.icon-copy-button:hover {
  background: white;
  color: var(--accent-strong);
}

.icon-copy-button:disabled {
  opacity: 0.35;
}

.icon-copy-button svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.78rem 0.9rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.check-row input {
  width: auto;
}

.status {
  margin: 0;
  min-height: 1.2rem;
  color: var(--danger);
  overflow-wrap: anywhere;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.ad-slot {
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.ad-slot.has-ad {
  display: block;
}

.ad-frame {
  display: block;
  width: 100%;
  min-height: 150px;
  border: 0;
}

.ad-slot-inline {
  max-width: 560px;
  margin-top: 1rem;
}

.ad-slot-compact {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.client {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(360px, 500px) minmax(0, 1fr);
  overflow: hidden;
}

.folders,
.messages,
.reader {
  height: 100vh;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(16px);
}

.folders {
  padding: 1rem;
  overflow: auto;
}

.brand {
  display: grid;
  gap: 0.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

#accountName {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

#logoutButton {
  justify-self: start;
}

.brand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.icon-refresh-button {
  display: inline-grid;
  place-items: center;
  width: 2.7rem;
  padding-inline: 0;
}

.icon-refresh-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.accounts-card {
  align-self: center;
}

.accounts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.accounts-head h2 {
  margin: 0 0 0.35rem;
}

.account-count {
  margin: 0.45rem 0 0;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 700;
}

.account-list {
  display: grid;
  gap: 0.65rem;
  max-height: calc(6 * 6.35rem + 5 * 0.65rem);
  overflow: auto;
  padding-right: 0.25rem;
}

.account-search {
  margin: 0.15rem 0 0.2rem;
}

.account-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 6.35rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.account-main {
  min-width: 0;
  text-align: left;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
}

.account-main:hover {
  background: rgba(15, 118, 110, 0.08);
}

.account-main strong,
.account-main span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.account-main span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.compose-button {
  width: 100%;
  margin: 1rem 0 0;
}

#folderList {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
}

.folder-button {
  width: 100%;
  text-align: left;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  overflow-wrap: anywhere;
}

.folder-button.active {
  background: var(--accent);
  color: white;
}

.messages {
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.toolbar,
.pager {
  display: flex;
  gap: 0.6rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.toolbar input {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.toolbar select {
  flex: 0 0 10.5rem;
  min-width: 10.5rem;
}

.toolbar button {
  flex: 0 0 auto;
}

.pager {
  align-items: center;
  justify-content: space-between;
}

.message-list {
  min-height: 0;
  overflow: auto;
}

.message-item {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 1rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.34);
  color: var(--ink);
  box-shadow: none;
}

.message-item:hover,
.message-item.active {
  background: rgba(15, 118, 110, 0.1);
}

.message-item strong,
.message-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.reader {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.75rem 6rem 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

#backToListButton {
  display: none;
  flex: 0 0 auto;
}

#readerState {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  place-self: center;
  max-width: 360px;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

#readerContent {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.reader-header {
  padding: 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  max-height: 34vh;
  overflow: auto;
}

.reader-header h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2.4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

dl {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.35rem 0.8rem;
  margin: 0;
  font-size: 0.92rem;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.attachments:empty {
  display: none;
}

.attachment-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.62);
  text-decoration: none;
}

.message-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: white;
}

.compose-dialog {
  width: min(720px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 0;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.compose-dialog::backdrop {
  background: rgba(24, 32, 38, 0.45);
  backdrop-filter: blur(5px);
}

.compose-dialog form {
  display: grid;
  gap: 0.85rem;
  padding: 1.2rem;
}

.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.compose-head h2 {
  margin: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  body:has(.client:not(.hidden)) {
    overflow: auto;
  }

  .key-panel,
  .login-panel,
  .accounts-panel {
    grid-template-columns: 1fr;
    padding: 2rem 0;
  }

  .language-switcher {
    top: 0.5rem;
    right: 0.5rem;
  }

  .client {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .folders,
  .messages,
  .reader {
    height: auto;
    min-height: auto;
    border-right: 0;
  }

  .reader,
  #readerContent {
    height: 75vh;
  }

}
