*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html, body {
  font-family: 'Google Sans', 'Roboto', 'Arial', sans-serif;
  color: #202124;
  background: #F9FBFD;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

/* =================== HEADER =================== */
.gd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 16px 0 16px;
  background: #F9FBFD;
}

.gd-header-left { display: flex; align-items: flex-start; gap: 4px; flex: 1; min-width: 0; }

.gd-doc-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: #4285F4;
  border-radius: 6px;
  margin-top: 8px; flex-shrink: 0;
  text-decoration: none;
}

.gd-title-block { display: flex; flex-direction: column; min-width: 0; }

.gd-title-row { display: flex; align-items: center; gap: 2px; padding: 4px 0 0 8px; }

.gd-title {
  font-family: inherit;
  font-size: 18px;
  color: #202124;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
  cursor: text;
}
.gd-title:hover { box-shadow: 0 0 0 1px #c4c7c5 inset; }

.gd-icon-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: #5f6368;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.gd-icon-btn:hover { background: rgba(60, 64, 67, 0.08); }

.gd-menu { display: flex; gap: 2px; padding: 2px 2px 4px 8px; }
.gd-menu button {
  font-size: 14px;
  color: #444746;
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.gd-menu button:hover { background: rgba(60, 64, 67, 0.08); }

.gd-header-right { display: flex; align-items: center; gap: 4px; padding-top: 10px; flex-shrink: 0; }

.gd-share-btn {
  background: #C2E7FF;
  color: #001D35;
  border: none;
  border-radius: 20px;
  padding: 0 22px 0 16px;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: 8px;
}
.gd-share-btn:hover { background: #B3DBFB; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }

.gd-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A73E8 0%, #4285F4 100%);
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px;
  margin-left: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

/* =================== TOOLBAR =================== */
.gd-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 10px;
  background: #EDF2FA;
  border-radius: 24px;
  margin: 6px 16px 0 16px;
  height: 40px;
  overflow: hidden;
}

.gd-tb-btn {
  min-width: 28px; height: 28px;
  border: none; background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: #444746;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.gd-tb-btn:hover { background: rgba(60, 64, 67, 0.12); }
.gd-tb-btn.active {
  background: #D3E3FD;
  color: #0B57D0;
}
.gd-tb-btn.active svg path { fill: #0B57D0; }

.tb-letter { font-size: 14px; display: inline-block; width: 14px; text-align: center; }

.gd-tb-divider { width: 1px; height: 20px; background: #C7C7C7; margin: 0 4px; flex-shrink: 0; }

.gd-dropdown {
  display: inline-flex; align-items: center;
  padding: 0 4px 0 8px; height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #444746;
  gap: 4px;
  background: transparent; border: none;
  white-space: nowrap;
}
.gd-dropdown:hover { background: rgba(60, 64, 67, 0.12); }

.gd-font-family { min-width: 108px; justify-content: space-between; }
.gd-dropdown-wide { min-width: 130px; justify-content: space-between; }

.gd-font-size {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 0 2px;
}
#font-size-input {
  width: 36px; height: 24px;
  text-align: center;
  border: 1px solid #C7C7C7;
  border-radius: 4px;
  background: white;
  font-family: inherit;
  font-size: 13px; color: #202124;
  outline: none;
  transition: box-shadow 0.2s;
}
#font-size-input.pulse { box-shadow: 0 0 0 2px #D3E3FD; border-color: #0B57D0; }

/* =================== RULER =================== */
.gd-ruler-wrap {
  display: flex; justify-content: center;
  padding: 6px 0 0 0;
  background: #F9FBFD;
}
.gd-ruler {
  width: 794px;
  height: 16px;
  background: #F9FBFD;
  position: relative;
  display: flex;
  justify-content: space-between;
}
.gd-ruler-margin {
  width: 96px;
  height: 100%;
  background:
    linear-gradient(to right, #E1E3E6 0%, #E1E3E6 100%);
  position: relative;
}
.gd-ruler-margin-left::after,
.gd-ruler-margin-right::before {
  content: '';
  position: absolute;
  top: 3px;
  width: 8px; height: 8px;
  background: #5f6368;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.gd-ruler-margin-left::after { right: -4px; }
.gd-ruler-margin-right::before { left: -4px; }

/* =================== WORKSPACE & PAGE =================== */
.gd-workspace {
  background: #F9FBFD;
  padding: 8px 0 80px 0;
  min-height: calc(100vh - 160px);
  overflow-y: auto;
}

.gd-page {
  width: 794px;          /* A4 at 96dpi */
  min-height: 1123px;    /* A4 height */
  margin: 0 auto 24px auto;
  background: white;
  box-shadow:
    0 1px 3px rgba(60,64,67,.15),
    0 4px 8px rgba(60,64,67,.15);
  padding: 96px 96px 96px 96px;
  border-radius: 2px;
}

.gd-page-inner {
  font-family: 'Arial', 'Helvetica', sans-serif;
  font-size: 11pt;
  line-height: 1.2;
  color: #000;
  min-height: 100%;
}

#doc-content {
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#doc-content p { margin: 0; padding: 0; }

/* Cursor */
.gd-cursor {
  display: inline-block;
  width: 1.8px;
  background: #202124;
  height: 1em;
  vertical-align: baseline;
  margin-left: -1px;
  margin-right: -1px;
  animation: gd-blink 1.06s steps(2, start) infinite;
  position: relative;
  top: 0.18em;
}
@keyframes gd-blink { to { visibility: hidden; } }

.gd-link { color: #1155cc; text-decoration: underline; }
.gd-link:hover { color: #0b5cb8; }
