:root {
  --ink: #142226;
  --teal: #0f6e6e;
  --teal-dark: #0c3d40;
  --paper: #f4f7f7;
  --line: #d5e1e1;
  --warn: #8a341f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 "Segoe UI", Calibri, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--teal-dark);
  color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; }
nav { display: flex; gap: 12px; }
nav a { color: #d7eeee; text-decoration: none; }
nav a[aria-current="page"] { color: #fff; font-weight: 700; }
.top-side { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.lang-pick, button, input, select, textarea {
  font: inherit;
  color: var(--ink);
}
button, .go {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.top button { background: transparent; color: #fff; border-color: transparent; }
.banner {
  margin: 0;
  padding: 8px 16px;
  background: #fff4df;
}
main { padding: 16px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.narrow { max-width: 640px; }
.tag { font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tools-home { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 22px 12px 18px; color: inherit; text-decoration: none;
}
.tool:hover { border-color: var(--teal); }
.tool strong { font-size: 1.05rem; }
.tool span { color: #5c7a7a; font-size: 0.92rem; }
.ico { width: 72px; height: 72px; border-radius: 18px; background: #e7f3f3; position: relative; }
.ico:before, .ico:after { content: ""; position: absolute; }
.ico.paper:before {
  left: 20px; top: 12px; width: 30px; height: 46px; border: 2px solid var(--teal);
  border-radius: 3px; background:
    linear-gradient(var(--teal), var(--teal)) 6px 12px / 16px 2px no-repeat,
    linear-gradient(var(--teal), var(--teal)) 6px 20px / 16px 2px no-repeat,
    linear-gradient(var(--teal), var(--teal)) 6px 28px / 10px 2px no-repeat,
    #fff;
}
.ico.count:before {
  left: 14px; top: 16px; width: 44px; height: 40px;
  background:
    linear-gradient(#fff, #fff) 0 0 / 100% 100% no-repeat,
    linear-gradient(var(--teal), var(--teal)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--teal), var(--teal)) 0 100% / 100% 2px no-repeat,
    linear-gradient(var(--teal), var(--teal)) 0 0 / 2px 100% no-repeat,
    linear-gradient(var(--teal), var(--teal)) 100% 0 / 2px 100% no-repeat,
    linear-gradient(#9bb0b0, #9bb0b0) 33% 0 / 1px 100% no-repeat,
    linear-gradient(#9bb0b0, #9bb0b0) 66% 0 / 1px 100% no-repeat,
    linear-gradient(#9bb0b0, #9bb0b0) 0 33% / 100% 1px no-repeat,
    linear-gradient(#9bb0b0, #9bb0b0) 0 66% / 100% 1px no-repeat;
}
.ico.present:before {
  left: 10px; top: 18px; width: 52px; height: 30px; border: 2px solid var(--teal);
  border-radius: 4px; background: #fff;
}
.ico.present:after { left: 26px; top: 50px; width: 20px; height: 4px; background: var(--teal); }
.ico.surat:before {
  left: 12px; top: 24px; width: 48px; height: 28px; border: 2px solid var(--teal);
  border-radius: 3px; background:
    linear-gradient(to bottom right, transparent 49%, var(--teal) 50% 52%, transparent 53%) left top / 50% 60% no-repeat,
    linear-gradient(to bottom left, transparent 49%, var(--teal) 50% 52%, transparent 53%) right top / 50% 60% no-repeat,
    #fff;
}
.grid a.card { color: inherit; text-decoration: none; }
.grid a.card:hover { border-color: var(--teal); }
label { display: block; margin-top: 10px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}
form button, .go { margin-top: 12px; background: var(--teal); color: #fff; border-color: var(--teal); }
.warn { color: var(--warn); min-height: 1.2em; }
.quiet { color: #5c7a7a; }
.foot { color: #5c7a7a; padding: 0 16px 24px; }
code { display: block; white-space: pre-wrap; background: #f7fbfb; border-radius: 6px; padding: 8px; }
.studio { display: grid; grid-template-columns: 220px 1fr; gap: 12px; min-height: calc(100vh - 120px); }
.studio aside { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.studio aside ul, #present-slides, #mail-list, #mail-accounts { list-style: none; margin: 8px 0 0; padding: 0; }
.studio aside li, #present-slides li, #mail-list li { padding: 6px; border-radius: 6px; cursor: pointer; }
.studio li.active { background: #e5f3f3; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.tools input[type="text"], .tools input:not([type]) { width: 220px; }
.tools button, .inline { margin: 0; }
.inline { display: flex; gap: 6px; align-items: center; }
.inline input { width: 42px; padding: 0; }
.page {
  width: min(820px, 100%);
  min-height: 980px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(20, 34, 38, 0.06);
  padding: 64px 72px;
  outline: none;
}
.page table { border-collapse: collapse; width: 100%; }
.page td { border: 1px solid #9bb0b0; min-width: 60px; padding: 4px; }
.formula-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.formula-bar span { width: 48px; }
.formula-bar input { flex: 1; }
.grid-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); max-height: calc(100vh - 220px); }
.grid-wrap table { border-collapse: collapse; }
.grid-wrap td, .grid-wrap th { border: 1px solid var(--line); min-width: 88px; height: 26px; padding: 0 4px; font-weight: 400; }
.grid-wrap th { background: #f7fbfb; position: sticky; top: 0; }
.grid-wrap td.focus { outline: 2px solid var(--teal); }
.present-wrap { display: grid; grid-template-columns: 160px 1fr; gap: 8px; }
#present-stage, #show-slide {
  position: relative;
  width: min(960px, 100%);
  aspect-ratio: 16 / 9;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}
.slide-item { position: absolute; overflow: hidden; }
.slide-item img { width: 100%; height: 100%; object-fit: contain; }
.mail-split { display: grid; grid-template-columns: 280px 1fr; gap: 8px; min-height: 420px; }
#mail-read { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; white-space: pre-wrap; }
#show {
  position: fixed;
  inset: 0;
  background: #111;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
#show-slide { width: min(1100px, 92vw); background: #fff; }
@media (max-width: 800px) {
  .tools-home { grid-template-columns: 1fr 1fr; }
  .studio, .present-wrap, .mail-split { grid-template-columns: 1fr; }
  .page { padding: 24px; }
}
@media print {
  .top, .banner, .tools, aside, .foot, #view-home, #view-gate, #view-count, #view-present, #view-surat { display: none !important; }
  #view-paper { display: block !important; }
  .page { border: 0; box-shadow: none; }
}
