:root {
  color-scheme: light;
  --desktop: #1f6f8b;
  --desktop-dark: #124659;
  --chrome: #d4d0c8;
  --chrome-dark: #808080;
  --chrome-darker: #404040;
  --chrome-light: #ffffff;
  --panel: #f3f2ef;
  --field: #ffffff;
  --title-start: #0a246a;
  --title-end: #a6caf0;
  --selection: #316ac5;
  --selection-soft: #d8e4f8;
  --text: #111111;
  --muted: #525252;
  --danger: #b00020;
  --success: #165d16;
  --shadow: rgba(0, 0, 0, 0.25);
  font-family: Tahoma, "MS Sans Serif", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 30%),
    linear-gradient(135deg, var(--desktop), var(--desktop-dark));
  color: var(--text);
}

body { min-height: 100vh; }
.hidden { display: none !important; }
.desktop, .boot-screen, .overlay { position: fixed; inset: 0; }
.boot-screen, .overlay {
  display: grid;
  place-items: center;
  background: rgba(13, 31, 46, 0.42);
  z-index: 30;
}

.boot-window, .window {
  width: min(1200px, calc(100vw - 40px));
  background: var(--chrome);
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
  box-shadow: 6px 8px 18px var(--shadow);
}

.boot-window {
  width: min(520px, calc(100vw - 40px));
  padding: 24px;
}

.boot-logo { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.boot-subtitle { color: var(--muted); margin-bottom: 16px; }
.boot-progress {
  height: 22px;
  padding: 3px;
  background: var(--field);
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
}

.boot-progress span {
  display: block;
  height: 100%;
  width: 48%;
  background: repeating-linear-gradient(90deg, #2c6bc7, #2c6bc7 14px, #7ea4e5 14px, #7ea4e5 28px);
  animation: progress 1.25s linear infinite;
}

@keyframes progress {
  from { transform: translateX(-12%); }
  to { transform: translateX(112%); }
}

.dialog { width: min(520px, calc(100vw - 28px)); }
.shell-window { margin: 18px auto; height: calc(100vh - 36px); display: flex; flex-direction: column; }

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 4px 2px 8px;
  color: white;
  background: linear-gradient(90deg, var(--title-start), var(--title-end));
}

.title-bar-text {
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}
.title-bar-controls { display: flex; gap: 4px; }
.title-bar-controls button {
  width: 18px;
  height: 16px;
  border-top: 1px solid var(--chrome-light);
  border-left: 1px solid var(--chrome-light);
  border-right: 1px solid var(--chrome-darker);
  border-bottom: 1px solid var(--chrome-darker);
  background: var(--chrome);
}

.window-body, .content-pane, .sidebar, .toolbar, .menu-bar, .status-bar { background: var(--chrome); }

.menu-bar, .toolbar, .status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-bottom: 1px solid #999;
}

.menu-bar { font-size: 12px; }
.menu-bar span {
  padding: 2px 6px;
  cursor: pointer;
  user-select: none;
}
.menu-bar span:hover,
.menu-bar span.menu-active {
  background: var(--selection-soft);
  color: var(--text);
}
.toolbar { gap: 8px; }
.tool-button, .button {
  min-height: 28px;
  padding: 4px 12px;
  font: inherit;
  background: var(--chrome);
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
  cursor: pointer;
}

.tool-button:active, .button:active {
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
}

.button.primary {
  background: linear-gradient(180deg, #eff6ff, #d4e3fb);
  border-color: #ffffff #3e5a92 #3e5a92 #ffffff;
}

.toolbar-spacer { flex: 1; }
.search-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  background: var(--field);
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
}

textarea { min-height: 120px; resize: vertical; }

.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
}

.pane { min-height: 0; }
.bevel-inset {
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
  border-right: 1px solid #8f8f8f;
}

.pane-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.top-gap { margin-top: 8px; }
.sidebar-tree { display: grid; gap: 2px; overflow: auto; }
.tree-group { margin-bottom: 6px; }
.tree-group-label { padding: 4px 6px; font-size: 11px; font-weight: 700; color: var(--muted); }

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.tree-item:hover, .list-row:hover, .grid-table tbody tr:hover { background: var(--selection-soft); }
.tree-item.active, .list-row.active { background: var(--selection); color: white; }
.tree-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 0 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.user-card {
  padding: 10px;
  background: var(--panel);
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
  font-size: 12px;
  line-height: 1.5;
}

.workbench { min-width: 0; min-height: 0; }
.content-pane { height: 100%; padding: 10px; overflow: auto; }
.mail-layout { display: grid; grid-template-rows: minmax(180px, 1fr) minmax(220px, 1fr); gap: 10px; min-height: 100%; }
.split-panel, .surface, .property-sheet {
  background: var(--panel);
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
}

.surface, .property-sheet { padding: 10px; }
.mail-list-head, .property-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid #a6a6a6;
  font-weight: 700;
}

.list-grid { display: grid; gap: 2px; }
.list-row {
  display: grid;
  grid-template-columns: 160px 1fr 150px;
  gap: 10px;
  padding: 6px 8px;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 12px;
}

.preview-stack { display: grid; gap: 10px; }
.message-card {
  background: #ffffff;
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
  padding: 10px;
}

.message-meta { font-size: 12px; line-height: 1.6; margin-bottom: 10px; }
.message-body {
  background: #fffffc;
  padding: 10px;
  border: 1px solid #d8d8d8;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-attachments { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
  background: var(--chrome);
  cursor: pointer;
}

.grid-table { width: 100%; border-collapse: collapse; background: white; }
.grid-table th, .grid-table td {
  padding: 6px 8px;
  border: 1px solid #9a9a9a;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

.grid-table th { background: #dbe3f3; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.connections-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.stack { display: grid; gap: 10px; }
.label { display: grid; gap: 4px; font-size: 12px; }
.label.compact { min-width: 0; }
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.mailbox-inline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dotted #c0c0c0;
}
.mailbox-inline-row:last-child {
  border-bottom: none;
}
.mailbox-row-active {
  background: #eef4ff;
}
.muted { color: var(--muted); }
.notice { padding: 8px 10px; background: #f8f3d6; border: 1px solid #d8c56f; font-size: 12px; }
.status-good { color: var(--success); }
.status-bad { color: var(--danger); }
.status-bar { border-top: 1px solid #a4a4a4; padding: 0; }
.status-cell {
  min-height: 24px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid #a4a4a4;
  font-size: 12px;
}

.effect-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

#eggOverlay {
  z-index: 80;
}

.egg-toast {
  position: absolute;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--chrome);
  border-top: 2px solid var(--chrome-light);
  border-left: 2px solid var(--chrome-light);
  border-right: 2px solid var(--chrome-darker);
  border-bottom: 2px solid var(--chrome-darker);
  box-shadow: 4px 6px 16px var(--shadow);
  font-size: 12px;
  animation: egg-toast-in 3.4s ease forwards;
}

.egg-toast strong {
  display: block;
  margin-bottom: 4px;
}

.egg-envelope {
  position: absolute;
  top: -64px;
  width: 46px;
  height: 32px;
  background: #fffdf7;
  border: 2px solid #7d7d7d;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
  animation: egg-envelope-fall var(--duration, 4s) linear forwards;
  transform: rotate(var(--rotation, 0deg));
}

.egg-envelope::before,
.egg-envelope::after {
  content: "";
  position: absolute;
  inset: 0;
}

.egg-envelope::before {
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #fefefe, #ece7da);
}

.egg-envelope::after {
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
  background: linear-gradient(180deg, #dfd7c8, #fefefe);
}

.pipes-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 27, 53, 0.22);
}

.pipe-segment {
  position: absolute;
  width: var(--width, 160px);
  height: var(--height, 18px);
  border: 4px solid var(--pipe-color, #9fc6ff);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  animation: pipe-drift var(--duration, 7s) linear forwards;
}

.egg-special-window {
  width: min(520px, calc(100vw - 28px));
}

.egg-window-body {
  padding: 14px;
}

.egg-window-copy {
  font-size: 12px;
  line-height: 1.6;
}

.egg-window-copy p {
  margin: 0 0 10px;
}

.egg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.bsod-screen {
  width: min(960px, calc(100vw - 24px));
  min-height: min(620px, calc(100vh - 24px));
  padding: 24px;
  background: #0000aa;
  color: #f4f4ff;
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 16px;
  line-height: 1.75;
  box-shadow: 0 0 0 2px #0000aa;
}

.bsod-screen strong {
  display: inline-block;
  margin-bottom: 18px;
  padding: 0 6px;
  background: #c0c0c0;
  color: #0000aa;
}

.task-list {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-top: 10px;
}

.task-list th,
.task-list td {
  padding: 6px 8px;
  border: 1px solid #9a9a9a;
  font-size: 12px;
  text-align: left;
}

.task-list th {
  background: #dbe3f3;
}

.mines-grid {
  display: grid;
  grid-template-columns: repeat(4, 34px);
  gap: 4px;
  margin-top: 12px;
}

.mine-cell {
  width: 34px;
  height: 34px;
  padding: 0;
  font-weight: 700;
}

.mine-cell.revealed {
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
  background: #ececec;
}

.egg-theme-matrix {
  --desktop: #09240f;
  --desktop-dark: #030f06;
  --title-start: #0a3514;
  --title-end: #2d8c40;
  --selection: #107c2a;
  --selection-soft: #d9f7df;
  --panel: #edf5ee;
}

.egg-theme-plus {
  --desktop: #38527a;
  --desktop-dark: #253651;
  --title-start: #6b2b19;
  --title-end: #f0bb74;
  --selection: #7a3a14;
  --selection-soft: #f8e2cc;
  --panel: #f7f1e6;
}

.shell-window.egg-shake {
  animation: egg-shake 0.45s linear 2;
}

@keyframes egg-toast-in {
  0% { opacity: 0; transform: translateY(30px); }
  10%, 80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(16px); }
}

@keyframes egg-envelope-fall {
  from {
    transform: translateY(0) rotate(var(--rotation, 0deg));
    opacity: 0.95;
  }
  to {
    transform: translateY(calc(100vh + 100px)) rotate(calc(var(--rotation, 0deg) + 24deg));
    opacity: 0.12;
  }
}

@keyframes pipe-drift {
  from {
    transform: translate3d(var(--from-x, 0), var(--from-y, 0), 0) rotate(var(--rotate, 0deg));
    opacity: 0.9;
  }
  to {
    transform: translate3d(var(--to-x, 0), var(--to-y, 0), 0) rotate(var(--rotate, 0deg));
    opacity: 0;
  }
}

@keyframes egg-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.login-dialog .window-body { padding: 18px; }
.login-copy h1 { margin: 0 0 8px; font-size: 24px; }
.login-copy p { margin: 0 0 14px; color: var(--muted); }

.compose-window {
  width: min(980px, calc(100vw - 30px));
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
}

.compose-window .window-body { padding: 10px; overflow: auto; }
.compose-body { min-height: 240px; }
.compose-tool-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #eef1f7;
  border: 1px solid #93a4c6;
}
.compose-mode-switch,
.compose-ai-row,
.compose-format-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.compose-mode-button.active {
  background: linear-gradient(180deg, #fff8d6, #f1d98a);
}
.compose-ai-prompt {
  flex: 1 1 260px;
}
.compose-static-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  background: #ffffff;
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
  font-size: 12px;
}
.compose-ai-note {
  font-size: 12px;
  line-height: 1.5;
}
.compose-editor,
.compose-html-source {
  width: 100%;
  min-height: 280px;
  padding: 10px;
  background: #ffffff;
  border-top: 2px solid var(--chrome-darker);
  border-left: 2px solid var(--chrome-darker);
  border-right: 2px solid var(--chrome-light);
  border-bottom: 2px solid var(--chrome-light);
}
.compose-editor {
  overflow: auto;
  line-height: 1.6;
  white-space: normal;
}
.compose-editor:focus,
.compose-html-source:focus {
  outline: 1px dotted #1c4fa1;
  outline-offset: -4px;
}
.compose-editor p {
  margin: 0 0 12px;
}
.compose-editor blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid #93a4c6;
  color: #3e4f68;
}
.compose-signature-block {
  margin-top: 12px;
}
.compose-html-source {
  resize: vertical;
  font-family: "Lucida Console", "Courier New", monospace;
  line-height: 1.5;
}
.format-underline { text-decoration: underline; }
.format-strike { text-decoration: line-through; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 6px; background: #ebeff8; border: 1px solid #8da1cb; font-size: 11px; }

@media (max-width: 980px) {
  .shell-window {
    width: calc(100vw - 10px);
    height: calc(100vh - 10px);
    margin: 5px;
  }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar { max-height: 220px; }
  .mail-layout { grid-template-rows: 240px 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .list-row { grid-template-columns: 1fr; }
}
