:root {
  color-scheme: light;
  --md-primary: #2196f3;
  --md-primary-dark: #1976d2;
  --md-primary-light: #bbdefb;
  --md-on-primary: #ffffff;
  --md-primary-container: #e3f2fd;
  --md-on-primary-container: #0d47a1;
  --md-surface: #ffffff;
  --md-surface-container-low: #f7fbff;
  --md-surface-container: #eef6ff;
  --md-surface-container-high: #e8f2fd;
  --md-background: #f5f9ff;
  --md-outline: #d4e3f4;
  --md-outline-variant: #e3edf9;
  --md-text: #172033;
  --md-muted: #607089;
  --md-error: #b3261e;
  --md-error-container: #ffdad6;
  --md-success: #146c2e;
  --md-success-container: #dcf5df;
  --md-shadow: 0 18px 46px rgba(25, 118, 210, 0.14);
  --md-shadow-soft: 0 8px 24px rgba(25, 118, 210, 0.10);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 34px;
  --sidebar-width: 420px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--md-background);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Roboto, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(187, 222, 251, 0.9), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, var(--md-background) 42%, #eef6ff 100%);
  color: var(--md-text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 4%, rgba(33, 150, 243, 0.20), transparent 24rem),
    radial-gradient(circle at 80% 96%, rgba(187, 222, 251, 0.48), transparent 28rem);
}

a {
  color: var(--md-primary-dark);
}

.app-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  border-right: 1px solid rgba(212, 227, 244, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(22px);
  z-index: 10;
}

.brand {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  color: var(--md-on-primary);
  background:
    linear-gradient(135deg, var(--md-primary-dark), var(--md-primary)),
    var(--md-primary);
  box-shadow: var(--md-shadow);
}

.brand::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  right: -80px;
  top: -92px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.brand-title {
  position: relative;
  display: block;
  color: var(--md-on-primary);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  position: relative;
  margin-top: 8px;
  max-width: 15rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.4;
}

.search-box {
  position: relative;
  margin: 18px 0 14px;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--md-outline);
  border-radius: 999px;
  padding: 0 16px 0 46px;
  outline: none;
  background: var(--md-surface-container-low);
  color: var(--md-text);
  font-size: 0.96rem;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.search-box::before {
  content: "⌕";
  position: absolute;
  left: 17px;
  top: 10px;
  z-index: 1;
  color: var(--md-primary-dark);
  font-size: 1.25rem;
  line-height: 1;
}

.search-box input:focus {
  border-color: var(--md-primary);
  background: var(--md-surface);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.13);
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 8px;
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  box-shadow: var(--md-shadow);
}

.search-result,
.search-empty {
  display: block;
  padding: 11px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--md-text);
  font-size: 0.92rem;
}

.search-result:hover {
  background: var(--md-primary-container);
}

.menu {
  margin-top: 4px;
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu > ul {
  display: grid;
  gap: 6px;
}

.folder {
  padding-top: 10px;
}

.folder details {
  border: none;
}

.folder details summary {
  cursor: pointer;
  list-style: none;
}

.folder details summary::-webkit-details-marker {
  display: none;
}

.folder details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 140ms ease;
}

.folder details[open] summary::before {
  transform: rotate(90deg);
}

.folder-title {
  margin: 10px 0 6px;
  padding: 0 12px;
  color: var(--md-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.folder ul {
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--md-outline-variant);
}

.doc-link {
  position: relative;
  display: block;
  margin: 3px 0;
  padding: 11px 13px 11px 38px;
  border-radius: 999px;
  color: #24364f;
  text-decoration: none;
  font-size: 0.94rem;
  line-height: 1.25;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.doc-link::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--md-primary-light);
}

.doc-link:hover {
  background: var(--md-primary-container);
}

.doc-link.active {
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  box-shadow: 0 10px 26px rgba(25, 118, 210, 0.25);
}

.doc-link.active::before {
  background: var(--md-on-primary);
}

.sync-card {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-md);
  background: var(--md-surface-container-low);
  font-size: 0.82rem;
}

.sync-label {
  color: var(--md-muted);
  font-weight: 700;
}

.sync-status {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: var(--md-primary-dark);
  font-weight: 800;
  text-transform: capitalize;
}

.status-error {
  color: var(--md-error);
  background: var(--md-error-container);
}

.status-ok {
  color: var(--md-success);
  background: var(--md-success-container);
}

.status-syncing,
.status-never_synced {
  color: var(--md-on-primary-container);
  background: var(--md-primary-container);
}

.sync-time,
.sync-error {
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--md-muted);
}

.sync-error {
  color: var(--md-error);
}

.content {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 4vw, 58px);
}

.doc-page,
.empty-state {
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid rgba(212, 227, 244, 0.9);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--md-shadow);
}

.doc-page {
  overflow: hidden;
}

.doc-header {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 36px 40px;
  border-bottom: 1px solid var(--md-outline-variant);
  background:
    linear-gradient(135deg, rgba(227, 242, 253, 0.92), rgba(255, 255, 255, 0.96)),
    var(--md-surface);
}

.doc-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3.4vw, 3.15rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.04;
  color: #102033;
}

.doc-header p {
  margin: 12px 0 0;
  color: var(--md-muted);
}

.open-drive,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  white-space: nowrap;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--md-on-primary);
  text-decoration: none;
  background: var(--md-primary-dark);
  box-shadow: var(--md-shadow-soft);
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
}

.open-drive:hover,
.menu-toggle:hover {
  background: var(--md-primary);
}

.google-doc-content {
  padding: 40px;
  font-size: 1.02rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.google-doc-content > *:first-child {
  margin-top: 0 !important;
}

.google-doc-content h1,
.google-doc-content h2,
.google-doc-content h3,
.google-doc-content h4,
.google-doc-content h5,
.google-doc-content h6 {
  margin: 1.45em 0 0.55em;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: #102033;
}

.google-doc-content h1 {
  font-size: 2rem;
}

.google-doc-content h2 {
  font-size: 1.55rem;
}

.google-doc-content h3 {
  font-size: 1.28rem;
}

.google-doc-content p {
  margin: 0 0 1.1em;
}

.google-doc-content a {
  font-weight: 700;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.google-doc-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 24px auto;
  border-radius: 22px;
  box-shadow: 0 16px 38px rgba(25, 118, 210, 0.16);
}

.google-doc-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  background: var(--md-surface);
}

.google-doc-content th,
.google-doc-content td {
  padding: 12px 14px;
  border-right: 1px solid var(--md-outline-variant);
  border-bottom: 1px solid var(--md-outline-variant);
  vertical-align: top;
}

.google-doc-content tr > *:last-child {
  border-right: 0;
}

.google-doc-content tr:last-child > * {
  border-bottom: 0;
}

.google-doc-content th {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  text-align: left;
  font-weight: 800;
}

.google-doc-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 5px solid var(--md-primary);
  border-radius: 16px;
  background: var(--md-primary-container);
  color: #20334c;
}

.google-doc-content pre,
.google-doc-content code {
  border-radius: 12px;
  background: #101827;
  color: #f8fafc;
}

.google-doc-content code {
  padding: 0.16em 0.38em;
}

.google-doc-content pre {
  padding: 18px;
  overflow: auto;
}

.video-embed {
  position: relative;
  width: 100%;
  margin: 30px 0;
  overflow: hidden;
  border-radius: 24px;
  background: #0b1020;
  box-shadow: 0 18px 46px rgba(25, 118, 210, 0.22);
}

.video-embed::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.alert {
  margin: 38px;
  padding: 18px;
  border: 1px solid rgba(179, 38, 30, 0.24);
  border-radius: 20px;
  background: var(--md-error-container);
  color: #601410;
}

.alert pre,
.empty-state pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 44px;
}

.empty-state h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.menu-toggle {
  display: none;
  margin-bottom: 18px;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 40px rgba(23, 32, 51, 0.12);
  }

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

  .content {
    padding: 18px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .doc-page,
  .empty-state {
    border-radius: 24px;
  }

  .doc-header {
    display: block;
    padding: 26px;
  }

  .open-drive {
    margin-top: 18px;
  }

  .google-doc-content {
    padding: 26px;
  }
}
