* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body:not(.index-page) {
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    color: #111111;
    background: #f5f5f5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

nav {
  position: sticky; top: 0; z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 64px 0 240px;
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
nav .left { display: flex; align-items: center; gap: 40px; }
nav .right { display: flex; align-items: center; }
nav .logo {
  display: flex;
  align-items: center;
  margin-left: 100px;
  text-decoration: none;
}
nav .logo img {
  height: 40px;
  width: auto;
}
nav .links { display: flex; gap: 32px; }
nav .links .nav-item {
  position: relative;
}
nav .links .nav-item > a {
  font-size: 16px; color: #111111; text-decoration: none;
  transition: color 0.2s; cursor: pointer;
}
nav .links .nav-item > a:hover { color: #111111; }
nav .links .nav-item > a.active { color: #111111; font-weight: 600; }
nav .links .nav-item .dropdown {
  display: none;
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  padding-top: 8px;
  z-index: 200;
  min-width: 160px;
}
nav .links .nav-item .dropdown::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
}
nav .links .nav-item .dropdown a {
  display: block;
  position: relative;
  padding: 10px 20px;
  font-size: 14px; color: #111111; text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
  z-index: 1;
}
nav .links .nav-item .dropdown a:first-child {
  padding-top: 14px;
}
nav .links .nav-item .dropdown a:last-child {
  padding-bottom: 14px;
}
nav .links .nav-item .dropdown a:hover {
  background: #f7f7f7;
}
nav .links .nav-item .dropdown a:hover .title {
  color: #111111;
}
nav .links .nav-item .dropdown a .title {
  color: #000000 !important;
  font-weight: 400;
}
nav .links .nav-item .dropdown a small {
  display: block;
  font-size: 12px;
  color: #6b6b6b !important;
  margin-top: 2px;
  font-weight: normal;
}
nav .links .nav-item .dropdown a.active {
  background: #f7f7f7;
}
nav .links .nav-item .dropdown a.active .title {
  font-weight: 600;
}
nav .links .nav-item:hover .dropdown { display: block; }
nav .links .nav-item:has(.dropdown) > a::after {
  content: " ▾";
  font-size: 10px; margin-left: 4px;
}
nav .right .btn-outline {
  display: inline-block;
  background: transparent; color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif; font-size: 12px; font-weight: 600;
  padding: 8px 22px; margin-right: 140px; border: 2px solid #111111; border-radius: 6px;
  text-decoration: none; transition: background 0.2s, color 0.2s;
}
nav .right .btn-outline:hover {
  background: #111111; color: #ffffff;
}

.mobile-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.mobile-warning-text {
  font-size: 18px;
  color: #111111;
  margin-bottom: 32px;
  line-height: 1.6;
}

.mobile-warning-btn {
  display: block;
  width: 200px;
  margin: 8px auto;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: #111111;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.mobile-warning-btn:hover {
  opacity: 0.85;
}

.mobile-warning-btn.outline {
  background: transparent;
  color: #111111;
  border: 2px solid #111111;
}

.mobile-warning-btn.outline:hover {
  background: #111111;
  color: #ffffff;
}

@media (max-width: 860px) {
  body:not(.index-page) .mobile-warning {
    display: flex;
  }
  body:not(.index-page) nav,
  body:not(.index-page) .main-container {
    display: none;
  }
}

.main-container {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 280px;
    background: #fff;
    padding: 20px;
    padding-top: 32px;
    border-right: 1px solid #e8e8e8;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section h3 {
    font-size: 14px;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8e8e8;
}

.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.zoom-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.zoom-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.control-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.control-group input[type="text"],
.control-group input[type="number"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
}

.control-group select {
    display: none;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.custom-select-trigger:hover {
    border-color: #000000;
}

.custom-select-trigger svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    margin-top: 4px;
    z-index: 1000;
    display: none;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.custom-select-dropdown.show {
    display: block;
}

.custom-select-option {
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-select-option:hover {
    background: #f5f5f5;
}

.custom-select-option.selected {
    background: #000000;
    color: #ffffff;
}

.control-group input[type="color"] {
    width: 60px;
    height: 32px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
}

.range-value {
    text-align: right;
    font-size: 12px;
    color: #999;
}

.switch-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.switch-group label {
    font-size: 13px;
    color: #333;
    cursor: pointer;
}

.switch {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 20px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.switch input:checked + .switch-slider {
    background-color: #000000;
}

.switch input:checked + .switch-slider:before {
    transform: translateX(16px);
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: #000000;
    color: #fff;
}

.btn-primary:hover {
    background: #333333;
}

.btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid #d9d9d9;
}

.btn-secondary:hover {
    border-color: #000000;
    color: #000000;
}

.content {
    flex: 1;
    padding: 16px;
    padding-top: 32px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #e8e8e8;
    max-height: calc(100vh - 60px);
}

.paper {
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    border-radius: 2px;
}

#letterCanvas,
#penCanvas {
    display: block;
}

.paper-info {
    text-align: center;
    padding: 8px;
    background: #fafafa;
    border-top: 1px solid #e8e8e8;
    font-size: 12px;
    color: #666;
}

@media print {
    .header, .sidebar, .paper-info {
        display: none !important;
    }

    .main-container {
        display: block;
    }

    .content {
        padding: 0;
        background: #fff;
    }

    .paper {
        box-shadow: none;
    }
}

.inline-inputs {
    display: flex;
    gap: 8px;
}

.inline-inputs input {
    flex: 1;
}

.margin-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    background: #fff;
}

.margin-input:hover {
    border-color: #000000;
}

.margin-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    width: 360px;
}

.margin-popup.show {
    display: block;
}

.margin-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
}

.margin-popup-overlay.show {
    display: block;
}

.margin-popup h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.margin-popup-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.margin-popup-row label {
    width: 90px;
    font-size: 13px;
    color: #666;
}

.margin-popup-row input[type="range"] {
    flex: 1;
    margin-right: 10px;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.margin-popup-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.margin-popup-row input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.margin-popup-row .value {
    width: 40px;
    text-align: right;
    font-size: 12px;
    color: #333;
}

.margin-popup-close {
    margin-top: 16px;
    text-align: right;
}

.margin-popup-close button {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    background: #000000;
    color: #fff;
}

.margin-popup-close button:hover {
    background: #333333;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

.color-picker:hover {
    border-color: #000000;
}

.color-preview {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.color-picker span {
    font-size: 13px;
    color: #333;
}

.color-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    width: 280px;
}

.color-popup.show {
    display: block;
}

.color-popup h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset.active {
    border-color: #000000;
}

.color-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.color-custom label {
    font-size: 13px;
    color: #666;
}

.color-custom input[type="color"] {
    width: 40px;
    height: 30px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
}

.color-popup-close {
    text-align: right;
}

.color-popup-close button {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    background: #000000;
    color: #fff;
}

.color-popup-close button:hover {
    background: #333333;
}

.zoom-control {
    margin-bottom: 20px;
}

.zoom-control label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.zoom-control .slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.zoom-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #000000;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.zoom-control .range-value {
    text-align: right;
    font-size: 12px;
    color: #999;
    min-width: 40px;
}

.export-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}

.export-modal-overlay.show {
    display: flex;
}

.export-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    text-align: center;
}

.export-modal-title {
    font-size: 14px;
    color: #333;
    margin-bottom: 20px;
}

.export-modal-btn {
    display: block;
    width: 180px;
    padding: 6px 12px;
    margin-bottom: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    text-align: center;
}

.export-modal-btn:last-child {
    margin-bottom: 0;
}

.export-modal-btn.primary {
    background: #000000;
    color: #fff;
}

.export-modal-btn.primary:hover {
    background: #333333;
}

.export-modal-btn.secondary {
    background: #f5f5f5;
    color: #333;
}

.export-modal-btn.secondary:hover {
    background: #e8e8e8;
}

.export-modal-btn.cancel {
    background: transparent;
    color: #666;
    border: 1px solid #d9d9d9;
}

.export-modal-btn.cancel:hover {
    border-color: #000000;
    color: #000000;
}

@media (max-width: 1100px) {
  nav { padding: 0 32px 0 80px; }
  nav .left { gap: 24px; }
  nav .logo { margin-left: 20px; }
  nav .links { gap: 16px; }
  nav .links .nav-item > a { font-size: 14px; }
  nav .right .btn-outline { margin-right: 20px; }
}
@media (max-width: 860px) {
  nav { padding: 0 24px; }
  nav .links { gap: 18px; }
}
@media (max-width: 520px) {
  nav .links { gap: 12px; }
  nav .links a { font-size: 13px; }
}
