/* SYNOP Encoder — styles */
:root {
  --blue-dark: #0e2a47;
  --blue: #1c5d99;
  --blue-light: #e8f1f9;
  --accent: #f0a02b;
  --text: #1d2733;
  --muted: #64748b;
  --border: #d7e0ea;
  --bg: #f2f5f9;
  --card: #ffffff;
  --error: #c0392b;
  --success: #1e824c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* Header */
#app-header {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff;
  padding: 18px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(14, 42, 71, 0.35);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-title { display: flex; align-items: center; gap: 14px; }
.header-icon { font-size: 2rem; color: var(--accent); }
#app-header h1 { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.02em; }
#app-header p { margin: 2px 0 0; font-size: 0.8rem; opacity: 0.85; }
.header-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Layout */
#app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 14px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(20, 40, 70, 0.06);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--blue-dark);
  border-bottom: 2px solid var(--blue-light);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 i { color: var(--blue); }
.card h3 { font-size: 0.85rem; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Fields */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; }
.field label { font-size: 0.82rem; font-weight: 600; margin-bottom: 5px; }
.field small { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.req { color: var(--error); }

input, select {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(28, 93, 153, 0.18);
}
input.invalid { border-color: var(--error); background: #fdf0ee; }

.field.disabled { opacity: 0.45; pointer-events: none; }

/* Cloud layers */
.layer-row {
  display: grid;
  grid-template-columns: auto repeat(3, 1fr);
  gap: 12px;
  align-items: end;
  padding: 10px 12px;
  margin-top: 12px;
  background: var(--blue-light);
  border-radius: 8px;
}
.layer-row .layer-tag {
  font-weight: 700;
  color: var(--blue-dark);
  font-size: 0.85rem;
  padding-bottom: 10px;
  white-space: nowrap;
}
.layer-row .field label { font-size: 0.75rem; }

/* Buttons */
#action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 18px;
  position: sticky;
  bottom: 10px;
  z-index: 40;
}
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); color: #fff; flex: 1 1 200px; justify-content: center; box-shadow: 0 3px 10px rgba(28, 93, 153, 0.4); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--accent); color: #3a2a05; }
.btn-secondary:hover { filter: brightness(1.06); }
.btn-ghost { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--error); border-color: var(--error); }

/* Output */
.output-card { border-left: 5px solid var(--success); }
.calc-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.calc-item {
  background: var(--blue-light);
  border-radius: 8px;
  padding: 10px 12px;
}
.calc-item .calc-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.calc-item .calc-value { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 1.05rem; color: var(--blue-dark); }

.synop-code {
  background: #0e2a47;
  color: #9fe3a1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 16px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
  user-select: all;
}

/* History */
.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fbfcfe;
}
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.history-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 8px;
  color: var(--blue-dark);
}
.history-actions { display: flex; gap: 8px; }
.mini-btn {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--blue);
}
.mini-btn.danger { color: var(--error); }
.mini-btn:hover { background: var(--blue-light); }

.muted { color: var(--muted); font-size: 0.85rem; }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--blue-dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.error { background: var(--error); }
#toast.success { background: var(--success); }

/* Footer */
#app-footer {
  text-align: center;
  padding: 18px 14px 30px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Mobile tweaks */
@media (max-width: 560px) {
  .header-clock { font-size: 0.78rem; padding: 5px 8px; }
  #app-header h1 { font-size: 1.05rem; }
  .layer-row { grid-template-columns: 1fr 1fr; }
  .layer-row .layer-tag { grid-column: 1 / -1; padding-bottom: 0; }
}
