:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dce1eb;
  --accent: #0b57d0;
  --sidebar: #0a2342;
  --sidebar-text: #e2ebff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #ffffff, var(--bg) 50%);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  position: relative;
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #12325c, var(--sidebar));
  color: var(--sidebar-text);
  padding: 18px;
  border-right: 1px solid #224f86;
  transition: transform 0.25s ease;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #9fb7e4;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #0b57d0;
  font-weight: 700;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item,
.menu-toggle,
.submenu-item {
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.menu-item:hover,
.menu-toggle:hover,
.submenu-item:hover {
  background: #173f73;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.submenu {
  display: none;
  padding-left: 8px;
}

.submenu.open {
  display: block;
}

.submenu-item {
  font-size: 14px;
  color: #d0ddff;
  white-space: normal;
}

.content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.topbar h1 {
  margin: 0;
  font-size: 20px;
  min-width: 0;
}

.topbar-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.blog-icon-link {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: inline-grid;
  place-items: center;
  color: #334155;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.blog-icon-link:hover {
  border-color: #b7c6e6;
  background: #eef3ff;
  color: var(--accent);
}

.blog-icon-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.lang-picker {
  position: relative;
}

.lang-trigger {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  border-radius: 10px;
  min-width: 72px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lang-trigger:hover {
  border-color: #b7c6e6;
}

.lang-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 87, 208, 0.12);
}

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  min-width: 90px;
  display: grid;
  gap: 4px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 30;
}

.lang-option {
  border: 0;
  background: transparent;
  color: #334155;
  border-radius: 8px;
  height: 30px;
  padding: 0 10px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.lang-option:hover {
  background: #e9efff;
  color: #0f172a;
}

.lang-option.active {
  background: var(--accent);
  color: #fff;
}

.menu-button {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.content {
  padding: 16px;
  flex: 1;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #f8faff;
  padding: 14px 16px 18px;
}

.site-footer-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.site-footer-links a {
  color: #1f3b6b;
  text-decoration: none;
  font-size: 14px;
}

.site-footer-links a:hover {
  text-decoration: underline;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.panel h2 {
  margin-top: 0;
}

.grid {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fcfdff;
}

.card h3 {
  margin: 0 0 8px;
}

.dashboard-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
  cursor: pointer;
}

.dashboard-card-link:hover {
  border-color: #b7c6e6;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.dashboard-card-close {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
}

.tool-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.editor {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 13px;
  resize: vertical;
}

.preview-frame {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions-wrap {
  flex-wrap: wrap;
}

.primary {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.error {
  color: #b42318;
  font-size: 13px;
}

.metric {
  color: var(--muted);
  font-size: 13px;
}

.success {
  color: #067647;
  font-size: 13px;
}

.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.tool-actions-wrap {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.history-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.history-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 28, 0.35);
  border: 0;
  z-index: 15;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .menu-button {
    display: inline-grid;
    place-items: center;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar.open + .content-wrap .overlay,
  .overlay[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
  }

  .lang-trigger {
    min-width: 64px;
  }
}
